var KOC = require("koc.common.utils");

var Config = require("../../config");

var StateData = require("../statedata");
var DALFactory = require("../../lib/dal/dal-factory");
var CommonUtils = require("../../lib/common-utils");
var FileBuilder = require("../../lib/file-builder");
var Interface_QCloud = require("../../lib/interface-qcloud");

module.exports = {
    Service: function (req, res) {
        var _UserData = StateData.Value(req, res);//取得状态
        switch (req.params.type) {
            //region Base
            case "base.logout":
                ajaxFactory.Base.Logout(req, res, _UserData);
                return;
            case "base.user-photo.avatar":
                ajaxFactory.Base.User_Photo.Avatar(req, res, _UserData);
                return;
            case "base.user-photo.cover":
                ajaxFactory.Base.User_Photo.Cover(req, res, _UserData);
                return;
            case "base.user-anchoridcard":
                ajaxFactory.Base.User_AnchorIDCard(req, res, _UserData);
                return;
            case "base.user-id-info":
                ajaxFactory.Base.User_ID_Info(req, res, _UserData);
                return;
            case "base.user-signin":
                ajaxFactory.Base.User_SignIn(req, res, _UserData);
                return;
            //endregion
            //region User
            case "user.user-info.page":
                ajaxFactory.User.User_Info.Page(req, res, _UserData);
                return;
            case "user.user-info.userinvitelist":
                ajaxFactory.User.User_Info.UserInviteList(req, res, _UserData);
                return;
            case "user.user-info.userinviteinfo":
                ajaxFactory.User.User_Info.UserInviteInfo(req, res, _UserData);
                return;
            case "user.user-info.consumelist":
                ajaxFactory.User.User_Info.ConsumeList(req, res, _UserData);
                return;
            case "user.user-info.paylist":
                ajaxFactory.User.User_Info.PayList(req, res, _UserData);
                return;
            case "user.user-anchor.livelist":
                ajaxFactory.User.User_Anchor.LiveList(req, res, _UserData);
                return;
            case "user.user-info.userblock":
                ajaxFactory.User.User_Info.UserBlock(req, res, _UserData);
                return;
            case "user.user-info.user-passwordreset":
                ajaxFactory.User.User_Info.User_PasswordReset(req, res, _UserData);
                return;
            case "user.user-info.admincurrencyupdate":
                ajaxFactory.User.User_Info.AdminCurrencyUpdate(req, res, _UserData);
                return;
            case "user.user-info.orderbankmange":
                ajaxFactory.User.User_Info.OrderBankManage(req, res, _UserData);
                return;
            case "user.user-info.grantitem":
                ajaxFactory.User.User_Info.GrantItem(req, res, _UserData);
                return;
            case "user.user-info.grantlist":
                ajaxFactory.User.User_Info.GrantList(req, res, _UserData);
                return;
            case "user.user-anchor.page":
                ajaxFactory.User.User_Anchor.Page(req, res, _UserData);
                return;
            case "user.user-anchor.anchorcheck":
                ajaxFactory.User.User_Anchor.AnchorCheck(req, res, _UserData);
                return;
            case "user.user-anchor.update":
                ajaxFactory.User.User_Anchor.Update(req, res, _UserData);
                return;
            case "user.user-anchor.anchorwithdraw":
                ajaxFactory.User.User_Anchor.AnchorWithdraw(req, res, _UserData);
                return;
            case "user.user-anchor.anchorwithdrawcheck":
                ajaxFactory.User.User_Anchor.AnchorWithdrawCheck(req, res, _UserData);
                return;
            case "user.user-anchor.anchorcover":
                ajaxFactory.User.User_Anchor.AnchorCover(req, res, _UserData);
                return;
            case "user.user-anchor.userphotolist":
                ajaxFactory.User.User_Anchor.UserPhotoList(req, res, _UserData);
                return;
            case "user.user-anchor.anchorcovercheck":
                ajaxFactory.User.User_Anchor.AnchorCoverCheck(req, res, _UserData);
                return;
            case "user.user-anchor.anchormovefamily":
                ajaxFactory.User.User_Anchor.AnchorMoveFamily(req, res, _UserData);
                return;
            case "user.user-anchor.pageanchorstatistics":
                ajaxFactory.User.User_Anchor.PageAnchorStatistics(req, res, _UserData);
                return;
            case "user.user-anchor.anchor-apply.page":
                ajaxFactory.User.User_Anchor.Anchor_Apply(req, res, _UserData);
                return;
            case "user.user-anchor.anchorlog":
                ajaxFactory.User.User_Anchor.AnchorLog(req, res, _UserData);
                return;
            case "user.family-info.familylist":
                ajaxFactory.User.Family_Info.FamilyList(req, res, _UserData);
                return;
            case "user.family-info.familycheck":
                ajaxFactory.User.Family_Info.FamilyCheck(req, res, _UserData);
                return;
            case "user.family-info.update":
                ajaxFactory.User.Family_Info.Update(req, res, _UserData);
                return;
            case "user.family-info.pagefamilystatistics":
                ajaxFactory.User.Family_Info.PageFamilyStatistics(req, res, _UserData);
                return;
            case "user.family-info.updatefamilystatus":
                ajaxFactory.User.Family_Info.UpdateFamilyStatus(req, res, _UserData);
                return;
            case "user.room-info.roomblock":
                ajaxFactory.User.Room_Info.RoomBlock(req, res, _UserData);
                return;
            case "user.statistics-info.user-day-statistics.page":
                ajaxFactory.User.Statistics_Info.User_Day_Statistics.Page(req, res, _UserData);
                return;
            case "user.statistics-info.anchor-day-statistics.page":
                ajaxFactory.User.Statistics_Info.Anchor_Day_Statistics.Page(req, res, _UserData);
                return;
            case "user.statistics-info.platform-day-statistics.page":
                ajaxFactory.User.Statistics_Info.Platform_Day_Statistics.Page(req, res, _UserData);
                return;
            case "user.statistics-info.channel-day-statistics.page":
                ajaxFactory.User.Statistics_Info.Channel_Day_Statistics.Page(req, res, _UserData);
                return;
            case "user.feedback-manage.page":
                ajaxFactory.User.FeedBack_Manage.Page(req, res, _UserData);
                return;
            case "user.brave-manage.page":
                ajaxFactory.User.Brave_Manage.Page(req, res, _UserData);
                return;
            case "user.admin-manage.page":
                ajaxFactory.User.Admin_Manage.Page(req, res, _UserData);
                return;
            case "user.admin-manage.enter-base":
                ajaxFactory.User.Admin_Manage.Enter_Base(req, res, _UserData);
                return;
            case "user.admin-manage.edit-base":
                ajaxFactory.User.Admin_Manage.Edit_Base(req, res, _UserData);
                return;
            case "user.admin-manage.loglist":
                ajaxFactory.User.Admin_Manage.LogList(req, res, _UserData);
                return;
            //endregion
        }
        res.jsonp({flag: -9999, msg: "未知的请求"});
    }
};

var ajaxFactory = {
    Base: {
        //region Logout:退出登录
        Logout: function (req, res, _UserData) {
            StateData.Clear(req, res);
            res.jsonp({flag: 0, msg: "退出完成"});
        },
        //endregion
        //region User_Photo:用户头像
        User_Photo: {
            Avatar: function (req, res, _UserData) {
                //region 判断权限??????
                if (!_UserData.IsAdmin) {
                    res.jsonp({flag: "-1", msg: "没有权限"});
                    return;
                }
                //endregion
                var parm = {
                    User_ID: req.params.User_ID,
                    FileName: KOC.StringUtils.ToString(req.params.FileName),
                    FileInfo: []

                };
                parm.FileInfo = parm.FileName.split(".");
                if (parm.FileInfo.length !== 2) {
                    res.jsonp({flag: 1, msg: "请上传图片"});
                    return;
                }
                KOC.Async.series([
                    //上传头像
                    function (callback) {
                        FileBuilder.User.Avatar.Build(parm.User_ID, FileBuilder.Common.TempFilePath(parm.FileInfo[0]), function (retValue) {
                            if (retValue.hasError) {
                                callback(retValue);
                                return;

                            }
                            callback();
                        });
                    },
                    //刷新cdn 头像url
                    function (callback) {
                        Interface_QCloud.RefreshUrl(FileBuilder.User.Avatar.UrlAll(parm.User_ID), function (retValue) {
                            if (retValue.hasError) {
                                callback(retValue);
                                return;
                            }
                            callback();
                        })
                    }
                ], function (retValue) {
                    if (retValue) {
                        res.jsonp({flag: retValue.errorCode, msg: retValue.message});
                        return;
                    }
                    res.jsonp({flag: 0, msg: "上传完成"});
                });
            },
            Cover: function (req, res, _UserData) {
                //region 判断权限??????
                if (!_UserData.IsAdmin) {
                    res.jsonp({flag: "-1", msg: "没有权限"});
                    return;
                }
                //endregion
                var parm = {
                    User_ID: req.params.User_ID,
                    FileName: KOC.StringUtils.ToString(req.params.FileName),
                    FileInfo: []
                };
                parm.FileInfo = parm.FileName.split(".");
                if (parm.FileInfo.length !== 2) {
                    res.jsonp({flag: 1, msg: "请上传图片"});
                    return;
                }
                KOC.Async.series([
                    //上传艺人封面
                    function (callback) {
                        FileBuilder.User.Cover.Build(parm.User_ID, FileBuilder.Common.TempFilePath(parm.FileInfo[0]), function (retValue) {
                            if (retValue.hasError) {
                                callback(retValue);
                                return;
                            }
                            callback();
                        });
                    },
                    //刷新cdn 艺人封面dir
                    function (callback) {
                        Interface_QCloud.RefreshDir(FileBuilder.User.Url(parm.User_ID, 'cover'), function (retValue) {
                            if (retValue.hasError) {
                                callback(retValue);
                                return;
                            }
                            callback();
                        })
                    }
                ], function (retValue) {
                    if (retValue) {
                        res.jsonp({flag: retValue.errorCode, msg: retValue.message});
                        return;
                    }
                    res.jsonp({flag: 0, msg: "上传完成"});
                });
            }
        },
        //endregion
        //region User_AnchorIDCard:艺人身份证图片上传
        User_AnchorIDCard: function (req, res, _UserData) {
            if (!_UserData.IsLogin) {
                res.jsonp({flag: -1, msg: "请登录后进行此操作"});
                return;
            }
            var parm = {
                User_ID: req.params.User_ID,
                FileName: KOC.StringUtils.ToString(req.params.FileName),
                FileInfo: [],
                Front: KOC.StringUtils.ToString(req.params.Front)
            };
            parm.FileInfo = parm.FileName.split(".");
            if (parm.FileInfo.length !== 2) {
                res.jsonp({flag: 1, msg: "请上传图片"});
                return;
            }
            KOC.Async.series([
                function (callback) {
                    DALFactory.User.User_Anchor.Info(parm.User_ID, function (retValue) {
                        if (retValue.hasError) {
                            callback(retValue);
                            return;
                        }
                        if (retValue.returnObject && retValue.returnObject.Status != 3 && retValue.returnObject.Status != 0) {
                            callback(KOC.ReturnValue.New({
                                hasError: true,
                                errorCode: 2,
                                message: "艺人信息已锁定或正在审批中不能上传身份证图片"
                            }));
                            return;
                        }
                        callback();
                    });
                },
                function (callback) {
                    FileBuilder.User.IDCard.Build(parm.User_ID, parm.Front, FileBuilder.Common.TempFilePath(parm.FileInfo[0]), function (retValue) {
                        if (retValue.hasError) {
                            callback(retValue);
                            return;
                        }
                        callback();
                    });
                },
                //刷新cdn 身份证正反url
                function (callback) {
                    Interface_QCloud.RefreshUrl(FileBuilder.User.IDCard.UrlAll(parm.User_ID, "idcard-" + parm.Front), function (retValue) {
                        if (retValue.hasError) {
                            callback(retValue);
                            return;
                        }
                        callback();
                    })
                }
            ], function (retValue) {
                if (retValue) {
                    res.jsonp({flag: retValue.errorCode, msg: retValue.message});
                    return;
                }
                res.jsonp({flag: 0, msg: "上传身份证图片完成"});
            });
        },
        //endregion
        //region User_ID_Info:查看用户信息
        User_ID_Info: function (req, res, _UserData) {
            if (!_UserData.IsLogin) {
                res.jsonp({flag: -1, msg: "请登录后进行此操作"});
                return;
            }
            if (!req.params.User_ID) {
                res.jsonp({flag: 7, msg: "请输入用户ID"});
                return;
            }
            DALFactory.User.User_Info.Info(req.params.User_ID, function (retValue) {
                if (retValue.hasError) {
                    res.jsonp({flag: retValue.errorCode, msg: retValue.message});
                    return;
                }
                if (!retValue.returnObject) {
                    res.jsonp({flag: -2, msg: "没有相应的用户，请重新输入"});
                    return;
                }
                res.jsonp({
                    flag: 0,
                    msg: "",
                    User_ID: retValue.returnObject.User_ID,
                    NickName: retValue.returnObject.NickName
                });
            });
        },
        //endregion
        //region User_SignIn:后台用户登录
        User_SignIn: function (req, res, _UserData) {
            var _UserData = StateData.Value(req, res);//取得状态
            if (_UserData.IsLogin) {
                res.jsonp({flag: -1, msg: "您已经登录"});
                return;
            }
            var _parm = {
                LoginName: req.params.LoginName,
                Password: req.params.Password,
                VerifyCode: req.params.VerifyCode,
                From_IP: KOC.StringUtils.GetClientIP(req)
            };
            DALFactory.Business.User_Login({
                LoginName: _parm.LoginName,
                Password: _parm.Password,
                SignIn_Origin: 0,
                SignIn_Type: 2,
                Create_IP: _parm.From_IP
            }, function (retValue) {
                if (retValue.hasError) {
                    res.jsonp({flag: retValue.errorCode, msg: retValue.message});
                    return;
                }
                //写入session
                StateData.Set(req, res, retValue.returnObject);
                //返回
                res.jsonp({
                    flag: 0,
                    msg: "登录完成",
                    _State: StateData.Value(req, res),
                    Address: Config.Common.Virtual_Path.Main
                });
            });
        }
        //endregion
    },
    User: {
        //region User_Info 用户信息
        User_Info: {
            //region Page 用户列表
            Page: function (req, res, _UserData) {
                var reqModel = CommonUtils.Common.AjaxPage.Request(req);

                //判断权限
                if (!_UserData.IsAdmin) {
                    res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("没有权限", reqModel.Echo));
                    return;
                }
                //查询参数
                var reqParm = new DALFactory.User.Page.UserInfo_Parm();
                if (reqModel.Filter_Value.length > 0) {
                    switch (reqModel.Filter_Type) {
                        case "Phone":
                            reqParm.Phone = reqModel.Filter_Value;
                            break;
                        case "User_ID":
                            reqParm.User_ID = reqModel.Filter_Value;
                            break;
                        case "Email":
                            reqParm.Email = reqModel.Filter_Value;
                            break;
                        case "NickName":
                            reqParm.NickName = reqModel.Filter_Value;
                            break;
                        default:
                            reqParm.FuzzyQuery = reqModel.Filter_Value;
                            break;
                    }
                }
                reqParm.Sex = KOC.StringUtils.ToInt(req.params.F_Sex);
                reqParm.IsAnchor = KOC.StringUtils.ToInt(req.params.F_IsAnchor, -1);
                reqParm.IsFamily = KOC.StringUtils.ToInt(req.params.F_IsFamily, -1);
                reqParm.Status = req.params.F_Status || reqParm.Status;
                //排序
                switch (reqModel.Sort_Col) {
                    case "User_ID":
                    case "EXP":
                    case "VIP":
                    case "VIP_Expire":
                    case "Coin":
                    case "Coin_Today":
                    case "Coin_Week":
                    case "Coin_Month":
                    case "Coin_Year":
                    case "Coin_Total":
                    case "Fans":
                    case "Beans":
                    case "Attention":
                    case "Login_Count":
                    case "Login_This_Date":
                        break;
                    default:
                        reqModel.Sort_Col = "`User_ID`";
                        break;
                }
                DALFactory.User.Page.UserInfo(reqParm, reqModel, function (retValue) {
                    if (retValue.hasError) {
                        res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode(retValue.message + "(" + retValue.errorCode + ")", reqModel.Echo));
                        return;
                    }
                    var PageData = CommonUtils.Common.AjaxPage.PageData(reqModel, retValue);
                    KOC.Lodash.forEach(retValue.returnObject, function (ThisValue) {
                        PageData.aaData.push({
                            User_ID: ThisValue.User_ID,
                            NickName: ThisValue.NickName,
                            QQ: ThisValue.QQ,
                            Sex: ThisValue.Sex,
                            Birthday: ThisValue.Birthday,
                            Constellation: ThisValue.Constellation,
                            Email: ThisValue.Email,
                            Phone: ThisValue.Phone,
                            EXP: ThisValue.EXP,
                            Level: CommonUtils.User.Level.fnLevel(ThisValue.EXP),
                            VIP: ThisValue.VIP && (!ThisValue.VIP_Expire || KOC.Moment().isBefore(retValue.returnObject.VIP_Expire)),
                            VIP_Expire: ThisValue.VIP_Expire,
                            Coin: ThisValue.Coin,
                            Coin_Today: ThisValue.Coin_Today,
                            Coin_Week: ThisValue.Coin_Week,
                            Coin_Month: ThisValue.Coin_Month,
                            Coin_Year: ThisValue.Coin_Year,
                            Coin_Total: ThisValue.Coin_Total,
                            Beans: ThisValue.Beans,
                            Beans_Today: ThisValue.Beans_Today,
                            Beans_Week: ThisValue.Beans_Week,
                            Beans_Month: ThisValue.Beans_Month,
                            Beans_Year: ThisValue.Beans_Year,
                            Beans_Total: ThisValue.Beans_Total,
                            Fans: ThisValue.Fans,
                            Attention: ThisValue.Attention,
                            IsAnchor: ThisValue.IsAnchor,
                            IsFamily: ThisValue.IsFamily,
                            Login_Count: ThisValue.Login_Count,
                            Login_This_Date: ThisValue.Login_This_Date,
                            Create_Date: ThisValue.Create_Date,
                            RoomName: ThisValue.RoomName,
                            RoomWelcome: ThisValue.RoomWelcome,
                            Tags: ThisValue.Tags,
                            Status: ThisValue.Status,
                            Live: ThisValue.Live,
                            Live_StartTime: ThisValue.Live_StartTime,
                            Live_Order_No: ThisValue.Live_Order_No,
                            Live_Duration_Total: ThisValue.Live_Duration_Total,
                            Anchor_Pomelo: ThisValue.Anchor_Pomelo,
                            Anchor_Pomelo_Today: ThisValue.Anchor_Pomelo_Today,
                            Anchor_Pomelo_Week: ThisValue.Anchor_Pomelo_Week,
                            Anchor_Pomelo_Month: ThisValue.Anchor_Pomelo_Month,
                            Anchor_Pomelo_Year: ThisValue.Anchor_Pomelo_Year,
                            Anchor_EXP: ThisValue.Anchor_EXP,
                            Anchor_Level: CommonUtils.Anchor.Level.fnLevel(ThisValue.Anchor_EXP).Level,
                            Anchor_Create_Date: ThisValue.Anchor_Create_Date ? KOC.Moment(ThisValue.Anchor_Create_Date).format('YYYY-MM-DD HH:mm:ss') : 0,
                            Anchor_Status: ThisValue.Anchor_Status,
                            Live_Coin: ThisValue.Live_Coin,
                            Gift_Num: ThisValue.Gift_Num,
                            Gift_Num_Anchor: ThisValue.Gift_Num_Anchor,
                            Gift_Num_User: ThisValue.Gift_Num_User,
                            Gift_Count: ThisValue.Gift_Count,
                            Gift_Count_Anchor: ThisValue.Gift_Count_Anchor,
                            Gift_Count_User: ThisValue.Gift_Count_User,
                            Gift_Coin: ThisValue.Gift_Coin,
                            Gift_Coin_Anchor: ThisValue.Gift_Coin_Anchor,
                            Gift_Coin_User: ThisValue.Gift_Coin_User,
                            Gift_Pond_Count: ThisValue.Gift_Pond_Count,
                            Gift_Pond_Coin: ThisValue.Gift_Pond_Coin,
                            Guardian_Count: ThisValue.Guardian_Count,
                            Guardian_Coin: ThisValue.Guardian_Coin,
                            Live_Pomelo: ThisValue.Live_Pomelo,
                            Live_Duration: ThisValue.Live_Duration,
                            Live_Create_Date: ThisValue.Live_Create_Date,
                            Live_Status: ThisValue.Live_Status,
                            OAuth_QQ_ID: ThisValue.OAuth_QQ_ID,
                            OAuth_Weibo_ID: ThisValue.OAuth_Weibo_ID,
                            OAuth_Weixin_ID: ThisValue.OAuth_Weixin_ID
                        });
                    });
                    res.jsonp(PageData);
                });
            },
            //endregion
            //region ConsumeList 消费记录-礼物管理
            ConsumeList: function (req, res, _UserData) {
                var reqModel = CommonUtils.Common.AjaxPage.Request(req);
                if (!_UserData.IsLogin) {
                    res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("请登录后使用此功能", reqModel.Echo));
                    return;
                }
                // 判断权限
                if (!_UserData.IsAdmin) {
                    res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("没有权限", reqModel.Echo));
                    return;
                }

                //查询参数
                var reqParm = new DALFactory.User.Page.OrderGiftOld_Parm();
                if (reqModel.Filter_Value.length > 0) {
                    switch (reqModel.Filter_Type) {
                        case "Live_Order_No":
                            //直播单据号
                            reqParm.Live_Order_No = reqModel.Filter_Value;
                            break;
                        case "User_NickName":
                            //用户昵称(送出人)
                            reqParm.User_NickName = reqModel.Filter_Value;
                            break;
                        case "User_NickName_Gift":
                            //用户昵称(接收人)
                            reqParm.User_NickName_Gift = reqModel.Filter_Value;
                            break;
                        case "Family_Name":
                            //公会名(接收人)
                            reqParm.Family_Name = reqModel.Filter_Value;
                            break;
                        case "Gift_Name":
                            //礼物商品名称
                            reqParm.Gift_Name = reqModel.Filter_Value;
                            break;
                        case "User_ID":
                            //送出者ＩＤ
                            reqParm.User_ID = reqModel.Filter_Value;
                            break;
                        default:
                            reqParm.FuzzyQuery = reqModel.Filter_Value;
                            break;
                    }
                }
                reqParm.User_ID = reqParm.User_ID ? reqParm.User_ID : (req.params.F_User_ID ? KOC.StringUtils.ToInt(req.params.F_User_ID) : null);
                reqParm.User_ID_Anchor = KOC.StringUtils.ToInt(req.params.User_ID_Anchor);
                reqParm.User_ID_Gift = KOC.StringUtils.ToInt(req.params.User_ID_Gift);
                reqParm.Family_ID = KOC.StringUtils.ToInt(req.params.Family_ID);
                reqParm.Gift_ID = KOC.StringUtils.ToInt(req.params.Gift_ID);
                reqParm.Gift_ID = KOC.StringUtils.ToInt(req.params.Gift_ID);
                reqParm.Create_Date_Between = req.params.F_StartDate ? req.params.F_StartDate : null;
                reqParm.Create_Date_And = req.params.F_EndDate ? req.params.F_EndDate : null;
                //传入Create_Date为字符串“2016-01”，查询一个月内的数据，特殊处理
                if (req.params.Create_Date) {
                    reqParm.Create_Date_Between = req.params.Create_Date ? req.params.Create_Date : null;
                    reqParm.Create_Date_And = req.params.Create_Date ? KOC.Moment(req.params.Create_Date).add(1, 'M').format("YYYY-MM-DD") : null;
                }
                //排序
                switch (reqModel.Sort_Col) {
                    case "Live_Order_No":
                    case "User_ID_Anchor":
                    case "User_NickName":
                    case "User_ID_Gift":
                    case "User_NickName_Gift":
                    case "Family_ID":
                    case "Family_Name":
                    case "Gift_ID":
                    case "Gift_Name":
                    case "Create_Date":
                    case "User_ID":
                        break;
                }
                DALFactory.User.Page.OrderGiftOld(reqParm, reqModel, function (retValue) {
                    if (retValue.hasError) {
                        res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode(retValue.message + "(" + retValue.errorCode + ")", reqModel.Echo));
                        return;
                    }
                    var PageData = CommonUtils.Common.AjaxPage.PageData(reqModel, retValue);
                    KOC.Lodash.forEach(retValue.returnObject, function (ThisValue) {
                        PageData.aaData.push({
                            Order_No: ThisValue.Order_No,
                            Live_Order_No: ThisValue.Live_Order_No,
                            User_ID_Anchor: ThisValue.User_ID_Anchor,
                            User_ID: ThisValue.User_ID,
                            NickName: ThisValue.User_NickName,
                            User_ID_Gift: ThisValue.User_ID_Gift,
                            User_NickName_Gift: ThisValue.User_NickName_Gift,
                            Family_ID: ThisValue.Family_ID,
                            Family_Name: ThisValue.Family_Name,
                            Gift_ID: ThisValue.Gift_ID,
                            Gift_Name: ThisValue.Gift_Name,
                            Gift_Price: ThisValue.Gift_Price,
                            Order_Num: ThisValue.Order_Num,
                            Order_Amt: ThisValue.Gift_Price * ThisValue.Order_Num,
                            Commission_Gift_Family: ThisValue.Commission_Gift_Family,
                            Commission_Gift_Anchor: ThisValue.Commission_Gift_Anchor,
                            Commission_Anchor_Family: ThisValue.Commission_Anchor_Family,
                            Order_Amt_Anchor: ThisValue.Order_Amt_Anchor,
                            Order_Amt_Platform: ThisValue.Order_Amt_Platform,
                            Order_Amt_Family: ThisValue.Order_Amt_Family,
                            Create_Date: ThisValue.Create_Date ? KOC.Moment(ThisValue.Create_Date).format('YYYY-MM-DD HH:mm:ss') : 0
                        });
                    });
                    res.jsonp(PageData);
                });
            },
            //endregion
            //region PayList 交易记录
            PayList: function (req, res, _UserData) {
                var reqModel = CommonUtils.Common.AjaxPage.Request(req);
                if (!_UserData.IsAdmin) {
                    res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("没有权限", reqModel.Echo));
                    return;
                }
                if (!_UserData.IsLogin) {
                    res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("请登录后使用此功能", reqModel.Echo));
                    return;
                }
                //查询参数
                var reqParm = new DALFactory.User.Page.OrderPay_Parm();
                if (reqModel.Filter_Value.length > 0) {
                    switch (reqModel.Filter_Type) {
                        case "User_NickName":
                            //用户名称
                            reqParm.User_NickName = reqModel.Filter_Value;
                            break;
                        case "User_ID":
                            //用户名称
                            reqParm.User_ID = reqModel.Filter_Value;
                            break;
                        case "Order_No":
                            //用户名称
                            reqParm.Order_No = reqModel.Filter_Value;
                            break;
                        case "Pay_TransNumber":
                            //支付返回的交易号
                            reqParm.Pay_TransNumber = reqModel.Filter_Value;
                            break;
                        default:
                            reqParm.FuzzyQuery = reqModel.Filter_Value;
                            break;
                    }
                }
                // reqParm.User_ID = KOC.StringUtils.ToInt(req.params.User_ID);
                // reqParm.User_NickName = KOC.StringUtils.ToInt(req.params.User_NickName);
                reqParm.Pay_Type = KOC.StringUtils.ToInt(req.params.Pay_Type);
                reqParm.Pay_Money_Between = KOC.StringUtils.ToInt(req.params.Pay_Money_Between);
                reqParm.Pay_Money_And = KOC.StringUtils.ToInt(req.params.Pay_Money_And);
                reqParm.Pay_TransNumber = KOC.StringUtils.ToInt(req.params.Pay_TransNumber);
                reqParm.Update_Date_Between = KOC.StringUtils.ToInt(req.params.Update_Date_Between);
                reqParm.Update_Date_And = KOC.StringUtils.ToInt(req.params.Update_Date_And);
                reqParm.Create_Date_Between = req.params.F_StartDate ? req.params.F_StartDate : null;
                reqParm.Create_Date_And = req.params.F_EndDate ? req.params.F_EndDate : null;
                reqParm.Status = req.params.F_Status ? KOC.StringUtils.ToInt(req.params.F_Status) : 0;
                //传入Create_Date为字符串“2016-01”，查询一个月内的数据，特殊处理
                if (req.params.Create_Date && req.params.Create_Date != "") {
                    reqParm.Create_Date_Between = req.params.Create_Date ? req.params.Create_Date : null;
                    reqParm.Create_Date_And = req.params.Create_Date ? KOC.Moment(req.params.Create_Date).add(1, 'M').format("YYYY-MM-DD") : null;
                }
                //排序
                switch (reqModel.Sort_Col) {
                    case "User_ID":
                    case "User_NickName":
                    case "Pay_Type":
                    case "Pay_Money":
                    case "Update_Date":
                    case "Create_Date":
                        break;
                }
                DALFactory.User.Page.OrderPay(reqParm, reqModel, function (retValue) {
                    if (retValue.hasError) {
                        res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode(retValue.message + "(" + retValue.errorCode + ")", reqModel.Echo));
                        return;
                    }
                    var PageData = CommonUtils.Common.AjaxPage.PageData(reqModel, retValue);
                    KOC.Lodash.forEach(retValue.returnObject, function (ThisValue) {
                        var Channel_ID = null;
                        var Channel_Name = {};
                        if (!ThisValue.Channel_ID) {
                            ThisValue.ChannelName = '平台';
                        } else if (ThisValue.Channel_ID.length < 3) {
                            ThisValue.ChannelName = '未知';
                        } else {
                            Channel_ID = ThisValue.Channel_ID.substring(0, 3);
                            Channel_Name = CommonUtils.Statistics.Channel.fnInfo(Channel_ID);
                            ThisValue.ChannelName = Channel_Name ? Channel_Name.Name : '未知';
                        }
                        PageData.aaData.push({
                            Order_No: ThisValue.Order_No,
                            User_ID: ThisValue.User_ID,
                            User_NickName: ThisValue.User_NickName,
                            Pay_Type: ThisValue.Pay_Type,
                            Pay_Money: ThisValue.Pay_Money,
                            Pay_Style: ThisValue.Pay_Style,
                            Pay_From: ThisValue.Pay_From,
                            Pay_Coin: ThisValue.Pay_Coin,
                            Pay_Poundage: ThisValue.Pay_Poundage,
                            TransNumber: ThisValue.Pay_TransNumber,
                            Update_Date: KOC.Moment(ThisValue.Update_Date).format('YYYY-MM-DD HH:mm:ss'),
                            Create_Date: KOC.Moment(ThisValue.Create_Date).format('YYYY-MM-DD HH:mm:ss'),
                            Create_IP: ThisValue.Create_IP,
                            Channel_Name: ThisValue.ChannelName,
                            Status: ThisValue.Status
                        });
                    });
                    res.jsonp(PageData);
                });
            },
            //endregion
            //region UserBlock 封号/解封
            UserBlock: function (req, res, _UserData) {
                // 判断权限
                if (!_UserData.IsAdmin) {
                    res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("没有权限"));
                    return;
                }
                if (!_UserData.IsLogin) {
                    res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("请登录后使用此功能"));
                    return;
                }
                var _Value = KOC.Lodash.extend({
                    User_ID: null,//封号、解封的用户ID
                    Status: null//1-封号，2-解封
                }, req.params);
                //参数判断
                if (!_Value.User_ID) {
                    res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("被操作的用户的ID不存在"));
                    return;
                }
                if (_Value.Status == '1') {
                    _Value.Status = 1;
                } else if (_Value.Status == '2') {
                    _Value.Status = 0;
                } else {
                    res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("参数错误：Status"));
                    return;
                }
                DALFactory.User.User_Info.Update_Status({
                    User_ID: _Value.User_ID,
                    Status: _Value.Status//1-封号，0-解封
                }, function (retValue) {
                    if (retValue.hasError) {
                        res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode(retValue.message));
                        return;
                    }
                    res.jsonp({flag: 0, msg: "操作成功", data: _Value});
                });
            },
            //endregion
            //region User_PasswordUpdate:重置密码
            User_PasswordReset: function (req, res, _UserData) {
                if (!_UserData.IsLogin) {
                    res.jsonp({flag: -1, msg: "请登录后进行此操作"});
                    return;
                }
                DALFactory.Business.User_PasswordReset({
                    User_ID: req.params.User_ID
                }, function (retValue) {
                    if (retValue.hasError) {
                        res.jsonp({flag: retValue.errorCode, msg: retValue.message});
                        return;
                    }
                    res.jsonp({flag: 0, msg: "密码重置完成", data: retValue.returnObject});
                });
            },
            //endregion
            //region AdminCurrencyUpdate 管理员修改金币
            AdminCurrencyUpdate: function (req, res, _UserData) {
                // 判断权限
                if (!_UserData.IsAdmin) {
                    res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("没有权限"));
                    return;
                }
                if (!_UserData.IsLogin) {
                    res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("请登录后使用此功能"));
                    return;
                }
                var _Value = KOC.Lodash.extend({
                    Type: null,//被操作的类型
                    User_ID: null,//被操作的用户
                    Trade_Flag: null,
                    Trade_Currency: null,
                    Trade_Amt: null,
                    Remark: null
                }, req.params);
                //参数判断
                if (!_Value.Trade_Amt || !parseInt(_Value.Trade_Amt) || parseInt(_Value.Trade_Amt) < 0) {
                    res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("参数错误：Trade_Amt"));
                    return;
                }
                if (!_Value.User_ID) {
                    res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("被操作的用户的ID不存在"));
                    return;
                }
                DALFactory.Business.User_AdminCurrencyUpdate({
                    Admin_ID: _UserData.User_ID,
                    Related_Type: _Value.Type,
                    Related_ID: _Value.User_ID,
                    Trade_Flag: _Value.Trade_Flag,
                    Trade_Currency: _Value.Trade_Currency,
                    Trade_Amt: _Value.Trade_Amt,
                    Remark: _Value.Remark,
                    Create_IP: KOC.StringUtils.GetClientIP(req)
                }, function (retValue) {
                    if (retValue.hasError) {
                        res.jsonp({flag: retValue.errorCode, msg: retValue.message});
                        return;
                    }
                    res.jsonp({flag: 0, msg: "操作成功", data: _Value});
                });
            },
            //endregion
            //region OrderBankmanage 后台管理修改金币列表
            OrderBankManage: function (req, res, _UserData) {
                var reqModel = CommonUtils.Common.AjaxPage.Request(req);
                //region 判断权限??????
                if (!_UserData.IsAdmin) {
                    res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("没有权限", reqModel.Echo));
                    return;
                }
                //endregion
                //查询参数
                var reqParm = new DALFactory.User.Page.OrderBankManage_Parm();
                if (reqModel.Filter_Value.length > 0) {
                    switch (reqModel.Filter_Type) {
                        case "Order_No":
                            reqParm.Order_No = reqModel.Filter_Value;
                            break;
                        case "NickName":
                            reqParm.NickName = reqModel.Filter_Value;
                            break;
                        case "RealName":
                            reqParm.RealName = reqModel.Filter_Value;
                            break;
                        case "Related_NickName":
                            reqParm.Related_NickName = reqModel.Filter_Value;
                            break;
                        case "Admin_ID":
                            reqParm.Admin_ID = reqModel.Filter_Value;
                            break;
                        case "Related_ID":
                            reqParm.Related_ID = reqModel.Filter_Value;
                            break;
                        default:
                            reqParm.FuzzyQuery = reqModel.Filter_Value;
                            break;
                    }
                }
                reqParm.Related_Type = KOC.StringUtils.ToInt(req.params.F_Related_Type);
                reqParm.Trade_Flag = KOC.StringUtils.ToInt(req.params.F_Trade_Flag);
                reqParm.Trade_Currency = KOC.StringUtils.ToInt(req.params.F_Trade_Currency);
                reqParm.Trade_Amt = KOC.StringUtils.ToInt(req.params.F_Trade_Amt);
                if (req.params.F_Create_Date_Between && req.params.F_Create_Date_And) {
                    reqParm.Create_Date_Between = KOC.Moment(req.params.F_Create_Date_Between)._d;
                    reqParm.Create_Date_And = KOC.Moment(req.params.F_Create_Date_And)._d;
                }
                //排序
                switch (reqModel.Sort_Col) {
                    case "Admin_ID":
                    case "Related_ID":
                    case "NickName":
                    case "RealName":
                    case "Order_No":
                        break;
                    case "Create_Date":
                        reqModel.Sort_Col = "Create_Date";
                        break;
                    default:
                        reqModel.Sort_Col = "Create_Date";
                        break;
                }
                DALFactory.User.Page.OrderBankManage(reqParm, reqModel, function (retValue) {
                    if (retValue.hasError) {
                        res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode(retValue.message + "(" + retValue.errorCode + ")", reqModel.Echo));
                        return;
                    }
                    var PageData = CommonUtils.Common.AjaxPage.PageData(reqModel, retValue);
                    KOC.Lodash.forEach(retValue.returnObject, function (ThisValue) {
                        PageData.aaData.push({
                            Order_No: ThisValue.Order_No,
                            Admin_ID: ThisValue.Admin_ID,
                            NickName: ThisValue.NickName,
                            RealName: ThisValue.RealName,
                            Related_Type: ThisValue.Related_Type,
                            Related_ID: ThisValue.Related_ID,
                            Related_NickName: ThisValue.Related_NickName,
                            Trade_Flag: ThisValue.Trade_Flag,
                            Trade_Currency: ThisValue.Trade_Currency,
                            Trade_Amt: ThisValue.Trade_Amt,
                            Remark: ThisValue.Remark,
                            Create_Date: ThisValue.Create_Date,
                            Create_IP: ThisValue.Create_IP
                        });
                    });
                    res.jsonp(PageData);
                });
            },
            //endregion
            //region GrantItem 发放物品
            GrantItem: function (req, res, _UserData) {
                // 判断权限
                if (!_UserData.IsAdmin) {
                    res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("没有权限"));
                    return;
                }
                if (!_UserData.IsLogin) {
                    res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("请登录后使用此功能"));
                    return;
                }
                var _Value = KOC.Lodash.extend({
                    Item_Type: null,//被操作的类型
                    User_ID: null,//被操作的用户
                    User_NickName: null,
                    Item_ID: null,
                    Item_Name: null,
                    Item_Expire: null,
                    Num: null,
                    Remark: null
                }, req.params);
                //参数判断
                if (!_Value.Num || _Value.Num <= 0) {
                    res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("数量错误"));
                    return;
                }
                DALFactory.Business.User_AdminItemGrant({
                    Admin_ID: _UserData.User_ID,
                    Item_Type: _Value.Item_Type,//被操作的类型
                    User_ID: _Value.User_ID,//被操作的用户
                    User_NickName: _Value.User_NickName,
                    Item_ID: _Value.Item_ID,
                    Item_Name: _Value.Item_Name,
                    Item_Expire: _Value.Item_Expire,
                    Num: _Value.Num,
                    Remark: _Value.Remark,
                    Create_IP: KOC.StringUtils.GetClientIP(req)
                }, function (retValue) {
                    if (retValue.hasError) {
                        res.jsonp({flag: retValue.errorCode, msg: retValue.message});
                        return;
                    }
                    res.jsonp({flag: 0, msg: "操作成功", data: _Value});
                });
            },
            //endregion
            //region GrantList 物品发放记录
            GrantList: function (req, res, _UserData) {
                var reqModel = CommonUtils.Common.AjaxPage.Request(req);
                if (!_UserData.IsAdmin) {
                    res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("没有权限", reqModel.Echo));
                    return;
                }
                if (!_UserData.IsLogin) {
                    res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("请登录后使用此功能", reqModel.Echo));
                    return;
                }
                //查询参数
                var reqParm = new DALFactory.User.Page.User_Item_Grant_Parm();
                if (reqModel.Filter_Value.length > 0) {
                    switch (reqModel.Filter_Type) {
                        case "User_NickName":
                            //用户名称
                            reqParm.User_NickName = reqModel.Filter_Value;
                            break;
                        case "User_ID":
                            //用户名称
                            reqParm.User_ID = reqModel.Filter_Value;
                            break;
                        default:
                            reqParm.FuzzyQuery = reqModel.Filter_Value;
                            break;
                    }
                }
                reqParm.Create_Date_Between = req.params.F_StartDate ? req.params.F_StartDate : null;
                reqParm.Create_Date_And = req.params.F_EndDate ? req.params.F_EndDate : null;
                //传入Create_Date为字符串“2016-01”，查询一个月内的数据，特殊处理
                if (req.params.Create_Date && req.params.Create_Date != "") {
                    reqParm.Create_Date_Between = req.params.Create_Date ? req.params.Create_Date : null;
                    reqParm.Create_Date_And = req.params.Create_Date ? KOC.Moment(req.params.Create_Date).add(1, 'M').format("YYYY-MM-DD") : null;
                }
                //排序
                switch (reqModel.Sort_Col) {
                    case "User_ID":
                    case "User_NickName":
                    case "Create_Date":
                        break;
                }
                DALFactory.User.Page.User_Item_Grant(reqParm, reqModel, function (retValue) {
                    if (retValue.hasError) {
                        res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode(retValue.message + "(" + retValue.errorCode + ")", reqModel.Echo));
                        return;
                    }
                    var PageData = CommonUtils.Common.AjaxPage.PageData(reqModel, retValue);
                    KOC.Lodash.forEach(retValue.returnObject, function (ThisValue) {
                        PageData.aaData.push({
                            ID: ThisValue.ID,
                            User_ID: ThisValue.User_ID,
                            User_NickName: ThisValue.User_NickName,
                            Item_Type: ThisValue.Item_Type,
                            Item_ID: ThisValue.Item_ID,
                            Item_Name: ThisValue.Item_Name,
                            Num: ThisValue.Num,
                            Item_Expire: ThisValue.Item_Expire,
                            Create_Date: KOC.Moment(ThisValue.Create_Date).format('YYYY-MM-DD HH:mm:ss'),
                            Create_IP: ThisValue.Create_IP,
                            Remark: ThisValue.Remark
                        });
                    });
                    res.jsonp(PageData);
                });
            },
            //endregion
        },
        //endregion
        //region User_Anchor 艺人信息
        User_Anchor: {
            Page: function (req, res, _UserData) {
                var reqModel = CommonUtils.Common.AjaxPage.Request(req);
                //region 判断权限??????
                if (!_UserData.IsAdmin) {
                    res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("没有权限", reqModel.Echo));
                    return;
                }
                //endregion
                //查询参数
                var reqParm = new DALFactory.User.Page.UserAnchor_Parm();
                if (reqModel.Filter_Value.length > 0) {
                    switch (reqModel.Filter_Type) {
                        case "Phone":
                            reqParm.Phone = reqModel.Filter_Value;
                            break;
                        case "User_ID":
                            reqParm.User_ID = reqModel.Filter_Value;
                            break;
                        case "Family_ID":
                            reqParm.Family_ID = reqModel.Filter_Value;
                            break;
                        case "Email":
                            reqParm.Email = reqModel.Filter_Value;
                            break;
                        case "NickName":
                            reqParm.NickName = reqModel.Filter_Value;
                            break;
                        case "RoomName":
                            reqParm.RoomName = reqModel.Filter_Value;
                            break;
                        case "Tags":
                            reqParm.Tags = reqModel.Filter_Value;
                            break;
                        default:
                            reqParm.FuzzyQuery = reqModel.Filter_Value;
                            break;
                    }
                }
                if (req.params.F_User_ID) {
                    reqParm.User_ID = KOC.StringUtils.ToInt(req.params.F_User_ID, -1);
                }
                if (req.params.F_NickName) {
                    reqParm.NickName = KOC.StringUtils.ToInt(req.params.F_NickName, '');
                }
                if (req.params.F_Family_ID) {
                    reqParm.Family_ID = KOC.StringUtils.ToInt(req.params.F_Family_ID, -1);
                }
                reqParm.Sex = KOC.StringUtils.ToIntPositive(req.params.F_Sex);
                reqParm.IsFamily = KOC.StringUtils.ToInt(req.params.F_IsFamily, -1);
                reqParm.Live = KOC.StringUtils.ToInt(req.params.F_Live, -1);
                reqParm.Status = KOC.StringUtils.ToInt(req.params.F_Status, -1);
                //排序
                switch (reqModel.Sort_Col) {
                    case "User_ID":
                    case "EXP":
                    case "VIP":
                    case "VIP_Expire":
                    case "Coin":
                    case "Coin_Today":
                    case "Coin_Week":
                    case "Coin_Month":
                    case "Coin_Year":
                    case "Coin_Total":
                    case "Beans":
                    case "Beans_Today":
                    case "Beans_Week":
                    case "Beans_Month":
                    case "Beans_Year":
                    case "Beans_Total":
                    case "Fans":
                    case "Attention":
                    case "Login_Count":
                    case "Login_This_Date":
                        break;
                    case "Create_Date":
                        reqModel.Sort_Col = "`User_ID`";
                        break;
                    case "Live":
                    case "Live_StartTime":
                    case "Live_Order_No":
                    case "Live_Duration_Total":
                    case "Anchor_Pomelo":
                    case "Anchor_Pomelo_Today":
                    case "Anchor_Pomelo_Week":
                    case "Anchor_Pomelo_Month":
                    case "Anchor_Pomelo_Year":
                    case "Anchor_EXP":
                    case "Anchor_HotValue":
                    case "Anchor_HotValue_Previous":
                    case "Anchor_Create_Date":
                        reqModel.Sort_Col = "`Create_Date`";
                        break;
                    case "Anchor_Status":
                        break;
                    case "Family_ID":
                        break;
                    case "New":
                        reqModel.Sort_Col = "`Live` DESC, `Live_Stream_Status` DESC, `Anchor_Create_Date` DESC";
                        reqModel.Sort_Dir = "";
                        break;
                    case "Hot":
                    default:
                        reqModel.Sort_Col = "`Live` DESC, `Live_Stream_Status` DESC";
                        reqModel.Sort_Dir = "";
                        break;
                }
                var PageData = null;
                KOC.Async.series([
                    //艺人数据
                    function (callback) {
                        DALFactory.User.Page.UserAnchor(reqParm, reqModel, function (retValue) {
                            if (retValue.hasError) {
                                callback(retValue);
                                return;
                            }
                            PageData = CommonUtils.Common.AjaxPage.PageData(reqModel, retValue);
                            KOC.Lodash.forEach(retValue.returnObject, function (ThisValue) {
                                PageData.aaData.push({
                                    User_ID: ThisValue.User_ID,
                                    NickName: ThisValue.NickName,
                                    RealName: ThisValue.RealName,
                                    RoomName: ThisValue.RoomName,
                                    RoomWelcome: ThisValue.RoomWelcome,
                                    RoomTemplate: ThisValue.RoomTemplate,
                                    RoomTitle: ThisValue.RoomTitle,
                                    RoomNotice: ThisValue.RoomNotice,
                                    Family_ID: ThisValue.Family_ID,
                                    Family_Name: ThisValue.Family_Name,
                                    Family_UserID: ThisValue.Family_UserID,
                                    QQ: ThisValue.QQ,
                                    Sex: ThisValue.Sex,
                                    EXP: ThisValue.EXP,
                                    Anchor_QQ: ThisValue.QQ,
                                    Anchor_Email: ThisValue.Email,
                                    Anchor_Phone: ThisValue.Phone,
                                    HotValue_Ranking: ThisValue.HotValue_Ranking,
                                    HotValue: ThisValue.HotValue,
                                    Anchor_HotValue: ThisValue.HotValue,
                                    ActivityNum: ThisValue.ActivityNum,
                                    Level: CommonUtils.User.Level.fnLevel(ThisValue.EXP),
                                    Beans: ThisValue.Beans,
                                    Beans_Today: ThisValue.Beans_Today,
                                    Beans_Week: ThisValue.Beans_Week,
                                    Beans_Month: ThisValue.Beans_Month,
                                    Beans_Year: ThisValue.Beans_Year,
                                    Beans_Total: ThisValue.Beans_Total,
                                    Fans: ThisValue.Fans,
                                    Attention: ThisValue.Attention,
                                    IsFamily: ThisValue.IsFamily,
                                    Tags: ThisValue.Tags ? ThisValue.Tags.split(",") : null,
                                    Live: ThisValue.Live,
                                    Live_StartTime: ThisValue.Live_StartTime,
                                    Live_Order_No: ThisValue.Live_Order_No,
                                    Live_Duration_Total: ThisValue.Live_Duration_Total,
                                    Live_IsMobile: ThisValue.Live_IsMobile,
                                    Live_Mode: ThisValue.Live_Mode,
                                    Live_Stream_LastDate: ThisValue.Live_Stream_LastDate,
                                    Live_Stream_Status: ThisValue.Live_Stream_Status,
                                    IsWeekStar: ThisValue.IsWeekStar,
                                    IsRecommend: ThisValue.IsRecommend,
                                    ProtectDue_Date: ThisValue.ProtectDue_Date,
                                    Rating: ThisValue.Rating,
                                    Score: ThisValue.Score,
                                    Integral: ThisValue.Integral,
                                    Integral_Month: ThisValue.Integral_Month,
                                    Integral_Month_Last: ThisValue.Integral_Month_Last,
                                    Integral_Week: ThisValue.Integral_Week,
                                    Integral_Week_Last: ThisValue.Integral_Week_Last,
                                    Integral_Date: ThisValue.Integral_Date,
                                    Anchor_Pomelo: ThisValue.Anchor_Pomelo,
                                    Anchor_Pomelo_Today: ThisValue.Anchor_Pomelo_Today,
                                    Anchor_Pomelo_Week: ThisValue.Anchor_Pomelo_Week,
                                    Anchor_Pomelo_Month: ThisValue.Anchor_Pomelo_Month,
                                    Anchor_Pomelo_Year: ThisValue.Anchor_Pomelo_Year,
                                    Anchor_EXP: ThisValue.Anchor_EXP,
                                    Anchor_Level: CommonUtils.Anchor.Level.fnLevel(ThisValue.Anchor_EXP).Level,
                                    ApplyMoney_LastDate: ThisValue.ApplyMoney_LastDate,
                                    Create_Date: ThisValue.Create_Date,
                                    Anchor_Create_Date: ThisValue.Create_Date,
                                    Status: ThisValue.Status,
                                    Anchor_Status: ThisValue.Status
                                });
                            });
                            callback();
                        });
                    },
                    //取得房间信息
                    function (callback) {
                        KOC.Async.each(PageData.aaData, function (ThisValue, callback) {
                            if (!ThisValue.Live) {
                                callback();
                                return;
                            }
                            DALFactory.RedisRoom.RoomInfo.Get(ThisValue.User_ID, function (retValue) {
                                if (retValue.hasError) {
                                    callback(retValue);
                                    return;
                                }
                                for (var i in PageData.aaData) {
                                    if (PageData.aaData[i].User_ID == retValue.returnObject.RoomID) {
                                        PageData.aaData[i].Live_Code = retValue.returnObject.Live_Code;
                                    }
                                }
                                callback();
                            });
                        }, function (retValue) {
                            callback();
                        })
                    }
                ], function (retValue) {
                    if (retValue) {
                        res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode(retValue.message + "(" + retValue.errorCode + ")", reqModel.Echo));
                        return;
                    }
                    res.jsonp(PageData);
                });
            },
            //region Anchor_Apply 艺人审核列表
            Anchor_Apply: function (req, res, _UserData) {
                var reqModel = CommonUtils.Common.AjaxPage.Request(req);
                //region 判断权限??????
                if (!_UserData.IsAdmin) {
                    res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("没有权限", reqModel.Echo));
                    return;
                }
                //endregion
                //查询参数
                var reqParm = new DALFactory.User.Page.UserAnchorApply_Parm();
                if (reqModel.Filter_Value.length > 0) {
                    switch (reqModel.Filter_Type) {
                        case "Phone":
                            reqParm.Phone = reqModel.Filter_Value;
                            break;
                        case "Email":
                            reqParm.Email = reqModel.Filter_Value;
                            break;
                        case "NickName":
                            reqParm.NickName = reqModel.Filter_Value;
                            break;
                        case "RoomName":
                            reqParm.RoomName = reqModel.Filter_Value;
                            break;
                        case "Tags":
                            reqParm.Tags = reqModel.Filter_Value;
                            break;
                        default:
                            reqParm.FuzzyQuery = reqModel.Filter_Value;
                            break;
                    }
                }
                reqParm.Sex = KOC.StringUtils.ToInt(req.params.F_Sex);
                reqParm.IsFamily = KOC.StringUtils.ToInt(req.params.F_IsFamily, -1);
                reqParm.Family_ID = KOC.StringUtils.ToInt(req.params.F_Family_ID, -1);
                reqParm.Live = KOC.StringUtils.ToInt(req.params.F_Live);
                reqParm.Status = req.params.F_Status || reqParm.Status;
                //排序
                switch (reqModel.Sort_Col) {
                    case "User_ID":
                    case "EXP":
                    case "VIP":
                    case "VIP_Expire":
                    case "Coin":
                    case "Coin_Today":
                    case "Coin_Week":
                    case "Coin_Month":
                    case "Coin_Year":
                    case "Coin_Total":
                    case "Beans":
                    case "Beans_Today":
                    case "Beans_Week":
                    case "Beans_Month":
                    case "Beans_Year":
                    case "Beans_Total":
                    case "Fans":
                    case "Attention":
                    case "Login_Count":
                    case "Login_This_Date":
                        break;
                    case "Create_Date":
                        reqModel.Sort_Col = "`User_ID`";
                        break;
                    case "Live":
                    case "Live_StartTime":
                    case "Live_Order_No":
                    case "Live_Duration_Total":
                    case "Anchor_Pomelo":
                    case "Anchor_Pomelo_Today":
                    case "Anchor_Pomelo_Week":
                    case "Anchor_Pomelo_Month":
                    case "Anchor_Pomelo_Year":
                    case "Anchor_EXP":
                    case "Anchor_HotValue":
                    case "Anchor_Create_Date":
                    case "Anchor_Status":
                        break;
                    case "Family_ID":
                        break;
                    case "New":
                        reqModel.Sort_Col = "`Live` DESC, `Anchor_Create_Date` DESC";
                        reqModel.Sort_Dir = "";
                        break;
                    case "Hot":
                    default:
                        reqModel.Sort_Col = "`Live` DESC, `Anchor_HotValue_Champion_Previous` DESC, `Anchor_HotValue` DESC, `Anchor_HotValue_Previous` DESC, `Live_Coin` DESC, `Beans_Month` DESC";
                        reqModel.Sort_Dir = "";
                        break;
                }
                DALFactory.User.Page.UserAnchorApply(reqParm, reqModel, function (retValue) {
                    if (retValue.hasError) {
                        res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode(retValue.message + "(" + retValue.errorCode + ")", reqModel.Echo));
                        return;
                    }
                    var PageData = CommonUtils.Common.AjaxPage.PageData(reqModel, retValue);
                    KOC.Lodash.forEach(retValue.returnObject, function (ThisValue) {
                        PageData.aaData.push({
                            User_ID: ThisValue.User_ID,
                            NickName: ThisValue.NickName,
                            RealName: ThisValue.RealName,
                            Email: ThisValue.Email,
                            Phone: ThisValue.Phone,
                            QQ: ThisValue.QQ,
                            Sex: ThisValue.Sex,
                            Birthday: ThisValue.Birthday,
                            Constellation: ThisValue.Constellation,
                            EXP: ThisValue.EXP,
                            Level: CommonUtils.User.Level.fnLevel(ThisValue.EXP),
                            VIP: ThisValue.VIP && (!ThisValue.VIP_Expire || KOC.Moment().isBefore(retValue.returnObject.VIP_Expire)),
                            VIP_Expire: ThisValue.VIP_Expire,
                            Coin: ThisValue.Coin,
                            Coin_Today: ThisValue.Coin_Today,
                            Coin_Week: ThisValue.Coin_Week,
                            Coin_Month: ThisValue.Coin_Month,
                            Coin_Year: ThisValue.Coin_Year,
                            Coin_Total: ThisValue.Coin_Total,
                            Beans: ThisValue.Beans,
                            Beans_Today: ThisValue.Beans_Today,
                            Beans_Week: ThisValue.Beans_Week,
                            Beans_Month: ThisValue.Beans_Month,
                            Beans_Year: ThisValue.Beans_Year,
                            Beans_Total: ThisValue.Beans_Total,
                            Pomelo: ThisValue.Pomelo,
                            Fans: ThisValue.Fans,
                            Attention: ThisValue.Attention,
                            IsAnchor: ThisValue.IsAnchor,
                            IsFamily: ThisValue.IsFamily,
                            Login_Count: ThisValue.Login_Count,
                            Login_This_Date: ThisValue.Login_This_Date,
                            Create_Date: ThisValue.Create_Date,
                            RoomName: ThisValue.RoomName,
                            RoomWelcome: ThisValue.RoomWelcome,
                            Tags: ThisValue.Tags,
                            Live: ThisValue.Live,
                            Live_StartTime: ThisValue.Live_StartTime,
                            Live_Order_No: ThisValue.Live_Order_No,
                            Live_Duration_Total: ThisValue.Live_Duration_Total,
                            Family_ID: ThisValue.Anchor_Family_ID,
                            Anchor_Email: ThisValue.Anchor_Email,
                            Anchor_Family_ID: ThisValue.Anchor_Family_ID,
                            Anchor_Phone: ThisValue.Anchor_Phone,
                            Anchor_Pomelo: ThisValue.Anchor_Pomelo,
                            Anchor_Pomelo_Today: ThisValue.Anchor_Pomelo_Today,
                            Anchor_Pomelo_Week: ThisValue.Anchor_Pomelo_Week,
                            Anchor_Pomelo_Month: ThisValue.Anchor_Pomelo_Month,
                            Anchor_Pomelo_Year: ThisValue.Anchor_Pomelo_Year,
                            Anchor_EXP: ThisValue.Anchor_EXP,
                            Anchor_Level: CommonUtils.Anchor.Level.fnLevel(ThisValue.Anchor_EXP).Level,
                            Anchor_Create_Date: ThisValue.Anchor_Create_Date ? KOC.Moment(ThisValue.Anchor_Create_Date).format('YYYY-MM-DD HH:mm:ss') : 0,
                            Anchor_Status: ThisValue.Anchor_Status,
                            IDCard: ThisValue.IDCard,
                            Account_BankName: ThisValue.Account_BankName,
                            Account_BankFullName: ThisValue.Account_BankFullName,
                            Account_RealName: ThisValue.Account_RealName,
                            Account_CardNo: ThisValue.Account_CardNo
                        });
                    });
                    res.jsonp(PageData);
                });
            },
            //endregion
            //region AnchorCheck 审批艺人申请入驻
            AnchorCheck: function (req, res, _UserData) {
                // 判断权限
                if (!_UserData.IsAdmin) {
                    res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("没有权限"));
                    return;
                }
                if (!_UserData.IsLogin) {
                    res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("请登录后使用此功能"));
                    return;
                }
                var _Value = KOC.Lodash.extend({
                    User_ID: null,
                    Status: null,///审批类型：1-申请成功，2-申请失败
                    Duty_Admin_ID: null,//责任人ID
                    Duty_RealName: null//责任人姓名
                }, req.params);
                //参数判断
                if (!_Value.Status || !parseInt(_Value.Status) || parseInt(_Value.Status) < 0) {
                    res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("参数错误：Status"));
                    return;
                }
                KOC.Async.series([
                    //查询管理员信息
                    function (callback) {
                        DALFactory.User.User_Admin.Info(_UserData.User_ID, function (retValue) {
                            if (retValue.hasError) {
                                callback(retValue);
                                return;
                            }
                            if (!retValue.returnObject) {
                                retValue.hasError = true;
                                retValue.message = '没有该管理员信息';
                                return;
                            }
                            _Value.RealName = retValue.returnObject.RealName;
                            _Value.Phone = retValue.returnObject.Phone;
                            callback();
                        });
                    },
                    //审核艺人
                    function (callback) {
                        DALFactory.Business.User_AnchorApplyCheck({
                            User_ID: _Value.User_ID,
                            Type: parseInt(_Value.Status),//审批类型：1-申请成功，2-申请失败
                            Approve_Admin_ID: _UserData.User_ID,
                            Approve_RealName: _Value.RealName,
                            Duty_Admin_ID: _Value.Duty_Admin_ID ? _Value.Duty_Admin_ID : null,
                            Duty_RealName: _Value.Duty_RealName ? _Value.Duty_RealName : null
                        }, function (retValue) {
                            if (retValue.hasError) {
                                callback(retValue);
                                return;
                            }
                            callback();
                        });
                    },
                    //添加log
                    function (callback) {
                        var _Merchant_Operation = {
                            Log_Type: 2,//1-用户，2-艺人，3-公会，4-房间，5-统计，6-财务，7-监控，8-系统',
                            Operate_Type: 2,//编辑-2
                            Operation: "艺人审核",//搜索标题
                            Related_ID: _Value.User_ID,
                            Data: '审核ID:' + _Value.User_ID + '的艺人',//描述
                            Admin_ID: _UserData.User_ID,
                            RealName: _Value.RealName,
                            Phone: _Value.Phone,
                            Create_IP: KOC.StringUtils.GetClientIP(req)
                        };
                        DALFactory.Log.Admin_Log.Insert(_Merchant_Operation, function (retValue) {
                            if (retValue.hasError) {
                                callback(retValue);
                                return;
                            }
                            if (retValue.returnObject !== 1) {
                                retValue.hasError = true;
                                retValue.message = "添加日志信息数据出错，影响行(" + retValue.returnObject + ")";
                                callback(retValue);
                                return;
                            }
                            callback();
                        });
                    }
                ], function (retValue) {
                    if (retValue) {
                        res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode(retValue.message));
                        return;
                    }
                    res.jsonp({flag: 0, msg: "审批成功"});
                });
            },
            //endregion
            //region Update 艺人信息修改
            Update: function (req, res, _UserData) {
                // 判断权限
                if (!_UserData.IsAdmin) {
                    res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("没有权限"));
                    return;
                }
                if (!_UserData.IsLogin) {
                    res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("请登录后使用此功能"));
                    return;
                }
                var _Value = KOC.Lodash.extend({
                    User_ID: null,
                    List_Order: null,
                    Tags: null,
                    Phone: null,
                    Account_BankName: null,
                    Account_BankFullName: null,
                    Account_Province: null,
                    Account_City: null,
                    Account_RealName: null,
                    Account_CardNo: null,
                    IDCard: null,
                    Duty_Admin_ID: null,//责任人ID
                    Duty_RealName: null,//责任人姓名
                    IsRecommend: null//是否推荐
                }, req.params);
                KOC.Async.series([
                    //查询当前推荐值
                    function (callback) {
                        DALFactory.User.User_Anchor.Info(_Value.User_ID, function (retValue) {
                            if (retValue.hasError) {
                                callback(retValue);
                                return;
                            }
                            if (!retValue.returnObject) {
                                retValue.hasError = true;
                                retValue.message = "没有该艺人信息";
                                callback(retValue);
                                return;
                            }
                            _Value.List_Order_Other = retValue.returnObject.List_Order;
                            callback();
                        })
                    },
                    //修改艺人信息
                    function (callback) {
                        DALFactory.User.User_Anchor.Update_ListOrder({
                            User_ID: _Value.User_ID,
                            List_Order: _Value.List_Order,
                            Tags: _Value.Tags,
                            Phone: _Value.Phone,
                            Account_BankName: _Value.Account_BankName,
                            Account_BankFullName: _Value.Account_BankFullName,
                            Account_Province: _Value.Account_Province,
                            Account_City: _Value.Account_City,
                            Account_RealName: _Value.Account_RealName,
                            Account_CardNo: _Value.Account_CardNo,
                            IDCard: _Value.IDCard,
                            IsRecommend: _Value.IsRecommend
                        }, function (retValue) {
                            if (retValue.hasError) {
                                callback(retValue);
                                return;
                            }
                            if (retValue.returnObject !== 1) {
                                retValue.hasError = true;
                                retValue.message = "修改艺人数据出错，影响行(" + retValue.returnObject + ")";
                                callback(retValue);
                                return;
                            }
                            callback();
                        });
                    },
                    //修改艺人责任人信息
                    function (callback) {
                        if (!_Value.Duty_Admin_ID || _Value.Duty_Admin_ID <= 0) {
                            callback();
                            return;
                        }
                        DALFactory.User.User_Anchor.Update_DutyAdmin(null, {
                            User_ID: _Value.User_ID,
                            Duty_Admin_ID: _Value.Duty_Admin_ID,//审批的管理员ID
                            Duty_RealName: _Value.Duty_RealName//审批的管理员姓名
                        }, function (retValue) {
                            if (retValue.hasError) {
                                callback(retValue);
                                return;
                            }
                            if (retValue.returnObject !== 1) {
                                retValue.hasError = true;
                                retValue.message = "修改艺人责任人信息，影响行(" + retValue.returnObject + ")";
                                callback(retValue);
                                return;
                            }
                            callback();
                        });
                    },
                    //查询管理员信息
                    function (callback) {
                        if (_Value.List_Order == _Value.List_Order_Other) {
                            callback();
                            return;
                        }
                        DALFactory.User.User_Admin.Info(_UserData.User_ID, function (retValue) {
                            if (retValue.hasError) {
                                callback(retValue);
                                return;
                            }
                            if (!retValue.returnObject) {
                                retValue.hasError = true;
                                retValue.message = '没有该管理员信息';
                                callback(retValue);
                                return;
                            }
                            _Value.RealName = retValue.returnObject.RealName;
                            _Value.Phone = retValue.returnObject.Phone;
                            callback();
                        });
                    },
                    //添加log
                    function (callback) {
                        if (_Value.List_Order == _Value.List_Order_Other) {
                            callback();
                            return;
                        }
                        var _Merchant_Operation = {
                            Log_Type: 2,//1-用户，2-艺人，3-公会，4-房间，5-统计，6-财务，7-监控，8-系统',
                            Operate_Type: 2,//编辑-2
                            Operation: "修改艺人推荐值",//搜索标题
                            Related_ID: _Value.User_ID,
                            Data: '修改艺人的推荐值从' + _Value.List_Order_Other + '改为' + _Value.List_Order,//描述
                            Admin_ID: _UserData.User_ID,
                            RealName: _Value.RealName,
                            Phone: _Value.Phone,
                            Create_IP: KOC.StringUtils.GetClientIP(req)
                        };
                        DALFactory.Log.Admin_Log.Insert(_Merchant_Operation, function (retValue) {
                            if (retValue.hasError) {
                                callback(retValue);
                                return;
                            }
                            if (retValue.returnObject !== 1) {
                                retValue.hasError = true;
                                retValue.message = "添加日志信息数据出错，影响行(" + retValue.returnObject + ")";
                                callback(retValue);
                                return;
                            }
                            callback();
                        });
                    }
                ], function (retValue) {
                    if (retValue) {
                        res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode(retValue.message + "(" + retValue.errorCode + ")"));
                        return;
                    }
                    res.jsonp({flag: 0, msg: "修改成功"});
                });
            },
            //endregion
            //region AnchorWithdraw 艺人申请提现列表
            AnchorWithdraw: function (req, res, _UserData) {
                var reqModel = CommonUtils.Common.AjaxPage.Request(req);
                //region 判断权限
                if (!_UserData.IsAdmin) {
                    res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("没有权限", reqModel.Echo));
                    return;
                }
                //endregion
                if (!_UserData.IsLogin) {
                    res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("请登录后使用此功能", reqModel.Echo));
                    return;
                }
                //查询参数
                var reqParm = new DALFactory.User.Page.OrderWithdraw_Parm();
                if (reqModel.Filter_Value.length > 0) {
                    switch (reqModel.Filter_Type) {
                        case "Order_No":
                            //单据号
                            reqParm.Order_No = reqModel.Filter_Value;
                            break;
                        case "User_ID":
                            //单据号
                            reqParm.User_ID = reqModel.Filter_Value;
                            break;
                        case "NickName":
                            //单据号
                            reqParm.NickName = reqModel.Filter_Value;
                            break;
                        default:
                            reqParm.FuzzyQuery = reqModel.Filter_Value;
                            break;
                    }
                }
                reqParm.User_ID = req.params.F_User_ID ? KOC.StringUtils.ToInt(req.params.F_User_ID) : (reqParm.User_ID ? reqParm.User_ID : null);
                reqParm.Order_No = req.params.F_Order_No ? req.params.F_Order_No : null;
                reqParm.Account_BankName = req.params.F_Account_BankName ? req.params.F_Account_BankName : null;
                reqParm.Account_BankFullName = req.params.F_Account_BankFullName ? req.params.F_Account_BankFullName : null;
                reqParm.Account_RealName = req.params.F_Account_RealName ? req.params.F_Account_RealName : null;
                reqParm.Account_CardNo = req.params.F_Account_CardNo ? req.params.F_Account_CardNo : null;
                reqParm.IDCard = req.params.F_IDCard ? req.params.F_IDCard : null;
                reqParm.Update_Date_Between = KOC.StringUtils.ToInt(req.params.F_Update_Date_Between);
                reqParm.Update_Date_And = KOC.StringUtils.ToInt(req.params.F_Update_Date_And);
                reqParm.Create_Date_Between = req.params.F_StartDate ? req.params.F_StartDate : null;
                reqParm.Create_Date_And = req.params.F_EndDate ? req.params.F_EndDate : null;
                reqParm.Status = req.params.F_Status == '0' || req.params.F_Status == '1' ? KOC.StringUtils.ToInt(req.params.F_Status) : null;
                //按月份的上中下旬查询，传入2016-06
                if (req.params.F_Create_Date && req.params.F_Create_Date != "" && req.params.F_Type) {
                    switch (req.params.F_Type) {
                        case "上旬":
                            reqParm.Create_Date_Between = req.params.F_StartDate ? req.params.F_StartDate : null;
                            reqParm.Create_Date_And = req.params.F_Create_Date ? KOC.Moment(req.params.F_Create_Date).add(10, 'd') : null;
                            break;
                        case "中旬":
                            reqParm.Create_Date_Between = req.params.F_Create_Date ? KOC.Moment(req.params.F_Create_Date).add(10, 'd') : null;
                            reqParm.Create_Date_And = req.params.F_Create_Date ? KOC.Moment(req.params.F_Create_Date).add(20, 'd') : null;
                            break;
                        case "下旬":
                            reqParm.Create_Date_Between = req.params.CreF_Create_Dateate_Date ? KOC.Moment(req.params.F_Create_Date).add(20, 'd') : null;
                            reqParm.Create_Date_And = req.params.F_Create_Date ? KOC.Moment(req.params.F_Create_Date).add(1, 'M') : null;
                            break;
                        default:
                            res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("传入类型错误：Type" + req.params.F_Type));
                            return;
                            break;
                    }
                }
                //排序
                switch (reqModel.Sort_Col) {
                    case "User_ID":
                    case "Order_No":
                    case "Update_Date":
                    case "Create_Date":
                        break;
                }
                DALFactory.User.Page.OrderWithdraw(reqParm, reqModel, function (retValue) {
                    if (retValue.hasError) {
                        res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode(retValue.message + "(" + retValue.errorCode + ")", reqModel.Echo));
                        return;
                    }
                    var PageData = CommonUtils.Common.AjaxPage.PageData(reqModel, retValue);
                    KOC.Lodash.forEach(retValue.returnObject, function (ThisValue) {
                        PageData.aaData.push({
                            Order_No: ThisValue.Order_No,
                            User_ID: ThisValue.User_ID,
                            Money: ThisValue.Money,
                            Revenue_Money: ThisValue.Revenue_Money,
                            Real_Money: ThisValue.Real_Money,
                            Update_Date: ThisValue.Update_Date,
                            Create_Date: ThisValue.Create_Date,
                            Status: ThisValue.Status,
                            NickName: ThisValue.NickName,
                            RealName: ThisValue.RealName,
                            Email: ThisValue.Email,
                            Phone: ThisValue.Phone,
                            QQ: ThisValue.QQ,
                            Sex: ThisValue.Sex,
                            Birthday: ThisValue.Birthday,
                            Constellation: ThisValue.Constellation,
                            EXP: ThisValue.EXP,
                            VIP: ThisValue.VIP,
                            VIP_ExpireEXP: ThisValue.VIP_Expire,
                            Beans: ThisValue.Beans,
                            Pomelo: ThisValue.Pomelo,
                            Fans: ThisValue.Fans,
                            Attention: ThisValue.Attention,
                            IsAnchor: ThisValue.IsAnchor,
                            IsFamily: ThisValue.IsFamily,
                            Login_Count: ThisValue.Login_Count,
                            Login_This_Date: ThisValue.Login_This_Date,
                            User_Create_Date: ThisValue.User_Create_Date,
                            Network: ThisValue.Network,
                            Account_BankName: ThisValue.Account_BankName,
                            Account_BankFullName: ThisValue.Account_BankFullName,
                            Account_RealName: ThisValue.Account_RealName,
                            Account_CardNo: ThisValue.Account_CardNo,
                            Account_Province: ThisValue.Account_Province,
                            Account_City: ThisValue.Account_City,
                            IDCard: ThisValue.IDCard,
                            Family_ID: ThisValue.Family_ID,
                            Anchor_Status: ThisValue.Anchor_Status
                        });
                    });
                    res.jsonp(PageData);
                });
            },
            //endregion
            //region AnchorWithdrawCheck 艺人申请提现结算（成功后操作）:金豆已扣除
            AnchorWithdrawCheck: function (req, res, _UserData) {
                var reqModel = CommonUtils.Common.AjaxPage.Request(req);
                //endregion
                if (!_UserData.IsLogin) {
                    res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("请登录后使用此功能", reqModel.Echo));
                    return;
                }
                // 判断权限
                if (!_UserData.IsAdmin) {
                    res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("没有权限"));
                    return;
                }
                DALFactory.User.Order_Withdraw.Update_Status({
                    Order_No: req.params.Order_No,
                    Status: true
                }, function (retValue) {
                    if (retValue.hasError) {
                        res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode(retValue.message + "(" + retValue.errorCode + ")"));
                        return;
                    }
                    res.jsonp({flag: 0, msg: "艺人申请提现结算成功"});
                });
            },
            //endregion
            //region AnchorCover 艺人海报列表
            AnchorCover: function (req, res, _UserData) {
                var reqModel = CommonUtils.Common.AjaxPage.Request(req);
                //region 判断权限
                if (!_UserData.IsAdmin) {
                    res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("没有权限", reqModel.Echo));
                    return;
                }
                //endregion
                if (!_UserData.IsLogin) {
                    res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("请登录后使用此功能", reqModel.Echo));
                    return;
                }
                //查询参数
                var reqParm = new DALFactory.User.Page.UserAnchorCover_Parm();
                if (reqModel.Filter_Value.length > 0) {
                    switch (reqModel.Filter_Type) {
                        case "User_ID":
                            reqParm.User_ID = reqModel.Filter_Value;
                            break;
                        case "NickName":
                            reqParm.NickName = reqModel.Filter_Value;
                            break;
                        default:
                            reqParm.User_ID = reqModel.Filter_Value;
                            break;
                    }
                }
                reqParm.User_ID = req.params.F_User_ID ? KOC.StringUtils.ToInt(req.params.F_User_ID) : null;
                reqParm.Type = req.params.F_Type ? KOC.StringUtils.ToInt(req.params.F_Type, 1) : 1;
                reqParm.NickName = req.params.F_NickName ? req.params.F_NickName : null;
                reqParm.Status = req.params.F_Status ? KOC.StringUtils.ToInt(req.params.F_Status) : null;
                reqParm.Create_Date_Between = req.params.F_StartDate ? req.params.F_StartDate : null;
                reqParm.Create_Date_And = req.params.F_EndDate ? req.params.F_EndDate : null;
                //排序
                switch (reqModel.Sort_Col) {
                    case"Create_Date":
                        reqModel.Sort_Col = "`Create_Date`";
                        break;
                    case"Status":
                        reqModel.Sort_Col = "`Create_Date`";
                        break;
                    case"User_ID":
                        reqModel.Sort_Col = "`User_ID`";
                        break;
                }
                DALFactory.User.Page.UserAnchorCover(reqParm, reqModel, function (retValue) {
                    if (retValue.hasError) {
                        res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode(retValue.message + "(" + retValue.errorCode + ")", reqModel.Echo));
                        return;
                    }
                    var PageData = CommonUtils.Common.AjaxPage.PageData(reqModel, retValue);
                    KOC.Lodash.forEach(retValue.returnObject, function (ThisValue) {
                        PageData.aaData.push({
                            User_ID: ThisValue.User_ID,
                            Type: ThisValue.Type,
                            NickName: ThisValue.NickName,
                            Status: ThisValue.Status,
                            Image: ThisValue.Image,
                            Create_Date: ThisValue.Create_Date,
                            Create_IP: ThisValue.Create_IP
                        });
                    });
                    res.jsonp(PageData);
                });
            },
            //endregion
            //region UserPhotoList 用户头像列表
            UserPhotoList: function (req, res, _UserData) {
                var reqModel = CommonUtils.Common.AjaxPage.Request(req);
                //region 判断权限
                if (!_UserData.IsAdmin) {
                    res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("没有权限", reqModel.Echo));
                    return;
                }
                //endregion
                if (!_UserData.IsLogin) {
                    res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("请登录后使用此功能", reqModel.Echo));
                    return;
                }
                //查询参数
                var reqParm = new DALFactory.User.Page.UserAnchorCover_Parm();
                if (reqModel.Filter_Value.length > 0) {
                    switch (reqModel.Filter_Type) {
                        case "User_ID":
                            reqParm.User_ID = reqModel.Filter_Value;
                            break;
                        case "NickName":
                            reqParm.NickName = reqModel.Filter_Value;
                            break;
                        default:
                            reqParm.User_ID = reqModel.Filter_Value;
                            break;
                    }
                }
                reqParm.User_ID = req.params.F_User_ID ? KOC.StringUtils.ToInt(req.params.F_User_ID) : null;
                reqParm.Type = req.params.F_Type ? KOC.StringUtils.ToInt(req.params.F_Type, 2) : 2;
                reqParm.NickName = req.params.F_NickName ? req.params.F_NickName : null;
                reqParm.Status = req.params.F_Status ? KOC.StringUtils.ToInt(req.params.F_Status) : null;
                reqParm.Create_Date_Between = req.params.F_StartDate ? req.params.F_StartDate : null;
                reqParm.Create_Date_And = req.params.F_EndDate ? req.params.F_EndDate : null;
                //排序
                switch (reqModel.Sort_Col) {
                    case"Create_Date":
                        reqModel.Sort_Col = "`Create_Date`";
                        break;
                    case"Status":
                        reqModel.Sort_Col = "`Create_Date`";
                        break;
                    case"User_ID":
                        reqModel.Sort_Col = "`User_ID`";
                        break;
                }
                DALFactory.User.Page.UserAnchorCover(reqParm, reqModel, function (retValue) {
                    if (retValue.hasError) {
                        res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode(retValue.message + "(" + retValue.errorCode + ")", reqModel.Echo));
                        return;
                    }
                    var PageData = CommonUtils.Common.AjaxPage.PageData(reqModel, retValue);
                    KOC.Lodash.forEach(retValue.returnObject, function (ThisValue) {
                        PageData.aaData.push({
                            User_ID: ThisValue.User_ID,
                            Type: ThisValue.Type,
                            NickName: ThisValue.NickName,
                            Status: ThisValue.Status,
                            Image: ThisValue.Image,
                            Create_Date: ThisValue.Create_Date,
                            Create_IP: ThisValue.Create_IP
                        });
                    });
                    res.jsonp(PageData);
                });
            },
            //endregion
            //region AnchorCoverCheck 艺人海报审核
            AnchorCoverCheck: function (req, res, _UserData) {
                var reqModel = CommonUtils.Common.AjaxPage.Request(req);
                //region 判断权限
                if (!_UserData.IsAdmin) {
                    res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("没有权限", reqModel.Echo));
                    return;
                }
                //endregion
                if (!_UserData.IsLogin) {
                    res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("请登录后使用此功能", reqModel.Echo));
                    return;
                }
                var _Value = KOC.Lodash.extend({
                    User_ID: null,
                    Type: null,//图片类型:1-海报，2-头像
                    Status: null///审批类型：0-申请成功，2-申请失败
                }, req.params);
                //参数判断
                if (!KOC.Lodash.includes([0, 2], parseInt(_Value.Status))) {
                    res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("参数错误：Status"));
                    return;
                }
                if (!KOC.Lodash.includes([1, 2], parseInt(_Value.Type))) {
                    res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("参数错误：Type"));
                    return;
                }
                KOC.Async.series([
                    //审核艺人海报信息
                    function (callback) {
                        DALFactory.Business.User_AnchorCoverCheck({
                            Admin_ID: _UserData.User_ID,//管理员ID
                            User_ID: _Value.User_ID,
                            Type: _Value.Type,//图片类型:1-海报，2-头像
                            Status: _Value.Status,//审批类型：0-申请成功，2-申请失败
                            Create_IP: KOC.StringUtils.GetClientIP(req)
                        }, function (retValue) {
                            if (retValue.hasError) {
                                callback(retValue);
                                return;
                            }
                            _Value.Image = retValue.returnObject;
                            callback();
                        });
                    },
                    //删除临时文件
                    function (callback) {
                        if (parseInt(_Value.Status) == 0) {
                            callback();
                            return;
                        }
                        FileBuilder.Common.TempFileRemove(_Value.Image.ImageName, function (retValue) {
                            if (retValue.hasError) {
                                callback(retValue);
                                return;
                            }
                            callback();
                        });
                    },
                    //上传图片文件
                    function (callback) {
                        if (parseInt(_Value.Status) == 2) {
                            callback();
                            return;
                        }
                        if (_Value.Type == 2) {
                            callback();
                            return;
                        }
                        FileBuilder.User.Cover.Build(_Value.User_ID, FileBuilder.Common.TempFilePath(_Value.Image.ImageName), function (retValue) {
                            if (retValue.hasError) {
                                callback(retValue);
                                return;
                            }
                            callback();
                        });
                    },
                    function (callback) {
                        if (parseInt(_Value.Status) == 2) {
                            callback();
                            return;
                        }
                        if (_Value.Type == 1) {
                            callback();
                            return;
                        }
                        FileBuilder.User.Avatar.Build(_Value.User_ID, FileBuilder.Common.TempFilePath(_Value.Image.ImageName), function (retValue) {
                            if (retValue.hasError) {
                                callback(retValue);
                                return;
                            }
                            callback();
                        });
                    },
                    //刷新cdn 艺人封面url
                    function (callback) {
                        Interface_QCloud.RefreshDir(FileBuilder.User.Url(_Value.User_ID, _Value.Type == 1 ? 'cover' : 'avatar'), function (retValue) {
                            if (retValue.hasError) {
                                callback(retValue);
                                return;
                            }
                            callback();
                        })
                    }
                ], function (retValue) {
                    if (retValue) {
                        res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode(retValue.message));
                        return;
                    }
                    res.jsonp({flag: 0, msg: "审批成功"});
                });
            },
            //endregion
            //region LiveList 艺人开播记录
            LiveList: function (req, res, _UserData) {
                var reqModel = CommonUtils.Common.AjaxPage.Request(req);
                if (!_UserData.IsLogin) {
                    res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("请登录后使用此功能", reqModel.Echo));
                    return;
                }
                if (!_UserData.IsAdmin) {
                    res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("没有权限", reqModel.Echo));
                    return;
                }
                //查询参数
                var reqParm = new DALFactory.User.Page.OrderLiveOld_Parm();
                if (reqModel.Filter_Value.length > 0) {
                    switch (reqModel.Filter_Type) {
                        case "User_ID":
                            //用户ID
                            reqParm.User_ID = reqModel.Filter_Value;
                            break;
                        case "User_NickName":
                            //用户名称
                            reqParm.User_NickName = reqModel.Filter_Value;
                            break;
                        case "Family_Name":
                            //公会名称
                            reqParm.Family_Name = reqModel.Filter_Value;
                            break;
                        default:
                            reqParm.FuzzyQuery = reqModel.Filter_Value;
                            break;
                    }
                }
                reqParm.User_ID = reqParm.User_ID ? reqParm.User_ID : (req.params.F_User_ID ? KOC.StringUtils.ToInt(req.params.F_User_ID) : null);
                reqParm.Family_ID = KOC.StringUtils.ToInt(req.params.Family_ID);
                reqParm.Coin_Between = KOC.StringUtils.ToInt(req.params.Coin_Between);
                reqParm.Coin_And = KOC.StringUtils.ToInt(req.params.Coin_And);
                reqParm.Duration_Between = KOC.StringUtils.ToInt(req.params.Duration_Between);
                reqParm.Duration_And = KOC.StringUtils.ToInt(req.params.Duration_And);
                reqParm.Create_Date_Between = req.params.F_StartDate ? req.params.F_StartDate : null;
                reqParm.Create_Date_And = req.params.F_EndDate ? req.params.F_EndDate : null;
                //传入Create_Date为字符串“2016-01”，查询一个月内的数据，特殊处理
                if (req.params.Create_Date) {
                    reqParm.Create_Date_Between = req.params.Create_Date ? req.params.Create_Date : null;
                    reqParm.Create_Date_And = req.params.Create_Date ? KOC.Moment(req.params.Create_Date).add(1, 'M').format("YYYY-MM-DD") : null;
                }
                //排序
                switch (reqModel.Sort_Col) {
                    case "User_ID":
                    case "Family_ID":
                    case "Coin":
                    case "Duration":
                    case "Create_Date":
                    case "User_NickName":
                    case "Family_Name":
                        break;
                }
                DALFactory.User.Page.OrderLiveOld(reqParm, reqModel, function (retValue) {
                    if (retValue.hasError) {
                        res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode(retValue.message + "(" + retValue.errorCode + ")", reqModel.Echo));
                        return;
                    }
                    var PageData = CommonUtils.Common.AjaxPage.PageData(reqModel, retValue);
                    KOC.Lodash.forEach(retValue.returnObject, function (ThisValue) {
                        PageData.aaData.push({
                            Order_No: ThisValue.Order_No,
                            User_ID: ThisValue.User_ID,
                            User_NickName: ThisValue.User_NickName,
                            Tags: ThisValue.Tags,
                            Coin: ThisValue.Coin,
                            Family_ID: ThisValue.Family_ID,
                            Family_Name: ThisValue.Family_Name,
                            Gift_Num: ThisValue.Gift_Num,
                            Gift_Num_Anchor: ThisValue.Gift_Num_Anchor,
                            Gift_Num_User: ThisValue.Gift_Num_User,
                            Gift_Count: ThisValue.Gift_Count,
                            Gift_Count_Anchor: ThisValue.Gift_Count_Anchor,
                            Gift_Count_User: ThisValue.Gift_Count_User,
                            Gift_Coin: ThisValue.Gift_Coin,
                            Gift_Coin_Anchor: ThisValue.Gift_Coin_Anchor,
                            Gift_Coin_User: ThisValue.Gift_Coin_User,
                            Gift_Beans_Anchor: ThisValue.Gift_Beans_Anchor,
                            Gift_Beans_Family: ThisValue.Gift_Beans_Family,
                            Gift_Beans_User: ThisValue.Gift_Beans_User,
                            Gift_Beans_UserFamily: ThisValue.Gift_Beans_UserFamily,
                            Gift_Pond_Count: ThisValue.Gift_Pond_Count,
                            Gift_Pond_Coin: ThisValue.Gift_Pond_Coin,
                            Guardian_Count: ThisValue.Guardian_Count,
                            Guardian_Coin: ThisValue.Guardian_Coin,
                            Pomelo: ThisValue.Pomelo,
                            Duration: ThisValue.Duration,
                            End_Date: KOC.Moment(ThisValue.End_Date).format('YYYY-MM-DD HH:mm:ss'),
                            Status: ThisValue.Status,
                            Create_Date: KOC.Moment(ThisValue.Create_Date).format('YYYY-MM-DD HH:mm:ss')
                        });
                    });
                    res.jsonp(PageData);
                });
            },
            //endregion
            //region LiveList 艺人罚分日志
            AnchorLog: function (req, res, _UserData) {
                var reqModel = CommonUtils.Common.AjaxPage.Request(req);
                if (!_UserData.IsLogin) {
                    res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("请登录后使用此功能", reqModel.Echo));
                    return;
                }
                if (!_UserData.IsAdmin) {
                    res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("没有权限", reqModel.Echo));
                    return;
                }
                //查询参数
                var reqParm = new DALFactory.User.Page.OrderAnchorIntegralOld_Parm();
                reqParm.User_ID = KOC.StringUtils.ToIntPositive(req.params.F_UserID);
                reqParm.User_NickName = req.params.F_UserNickName;
                reqParm.User_RealName = req.params.F_UserRealName;
                reqParm.User_ID_Admin = KOC.StringUtils.ToIntPositive(req.params.F_UserIDAdmin);
                reqParm.User_NickName_Admin = req.params.F_UserNickNameAdmin;
                reqParm.User_RealName_Admin = req.params.F_UserRealNameAdmin;
                reqParm.Family_ID = KOC.StringUtils.ToIntPositive(req.params.F_FamilyID);
                reqParm.Operation = KOC.StringUtils.ToInt(req.params.F_Operation, -1);
                reqParm.StartDate = req.params.F_StartDate ? req.params.F_StartDate : null;
                reqParm.EndDate = req.params.F_EndDate ? req.params.F_EndDate : null;
                if (reqModel.Filter_Value.length) {
                    switch (reqModel.Filter_Type) {
                        case "User_ID":
                        case "User_NickName":
                        case "User_RealName":
                        case "User_ID_Admin":
                        case "User_NickName_Admin":
                        case "User_RealName_Admin":
                        case "Family_ID":
                        case "Family_Name":
                            reqParm[reqModel.Filter_Type] = reqParm[reqModel.Filter_Type] || reqModel.Filter_Value;
                            break;
                        default:
                            reqParm.FuzzyQuery = reqModel.Filter_Value;
                            break;
                    }
                }
                //传入Create_Date为字符串“2016-01”，查询一个月内的数据，特殊处理
                if (req.params.Create_Date) {
                    reqParm.Create_Date_Between = req.params.Create_Date ? req.params.Create_Date : null;
                    reqParm.Create_Date_And = req.params.Create_Date ? KOC.Moment(req.params.Create_Date).add(1, 'M').format("YYYY-MM-DD") : null;
                }
                //排序
                switch (reqModel.Sort_Col) {
                    case "Order_No":
                    case "User_ID":
                    case "Family_ID":
                    case "User_NickName":
                    case "User_ID_Admin":
                    case "User_NickName_Admin":
                    case "Family_Name":
                    case "Integral":
                        reqModel.Sort_Col = "`" + reqModel.Sort_Col + "`";
                        break;
                    default:
                        reqModel.Sort_Col = "`Order_No`";
                        break;
                }
                DALFactory.User.Page.OrderAnchorIntegralOld(reqParm, reqModel, function (retValue) {
                    if (retValue.hasError) {
                        res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode(retValue.message + "(" + retValue.errorCode + ")", reqModel.Echo));
                        return;
                    }
                    var PageData = CommonUtils.Common.AjaxPage.PageData(reqModel, retValue);
                    PageData.aaData = retValue.returnObject;
                    res.jsonp(PageData);
                });
            },
            //endregion
            //region AnchorMoveFamily 艺人转公会
            AnchorMoveFamily: function (req, res, _UserData) {
                var reqModel = CommonUtils.Common.AjaxPage.Request(req);
                //region 判断权限
                if (!_UserData.IsAdmin) {
                    res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("没有权限", reqModel.Echo));
                    return;
                }
                //endregion
                if (!_UserData.IsLogin) {
                    res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("请登录后使用此功能", reqModel.Echo));
                    return;
                }
                var _Value = KOC.Lodash.extend({
                    User_ID: null,
                    Family_ID: null
                }, req.params);
                DALFactory.Business.User_AnchorMoveFamily({
                    User_ID: _Value.User_ID,
                    Family_ID: _Value.Family_ID
                }, function (retValue) {
                    if (retValue) {
                        res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode(retValue.message));
                        return;
                    }
                    res.jsonp({flag: 0, msg: "艺人转公会成功"});
                });
            },
            //endregion
            //region PageAnchorStatistics 艺人统计数据
            PageAnchorStatistics: function (req, res, _UserData) {
                var reqModel = CommonUtils.Common.AjaxPage.Request(req);
                //region 判断权限??????
                if (!_UserData.IsAdmin) {
                    res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("没有权限", reqModel.Echo));
                    return;
                }
                //endregion
                //查询参数
                var reqParm = new DALFactory.Report.Page.AdminAnchorStatistics_Parm();
                if (reqModel.Filter_Value.length > 0) {
                    switch (reqModel.Filter_Type) {
                        case "User_ID":
                            reqParm.User_ID = reqModel.Filter_Value;
                            break;
                        case "NickName":
                            reqParm.NickName = reqModel.Filter_Value;
                            break;
                        case "Family_ID":
                            reqParm.Family_ID = reqModel.Filter_Value;
                            break;
                        default:
                            reqParm.FuzzyQuery = reqModel.Filter_Value;
                            break;
                    }
                }
                if (req.params.F_User_ID) {
                    reqParm.User_ID = KOC.StringUtils.ToInt(req.params.F_User_ID);
                }
                if (req.params.F_NickName) {
                    reqParm.NickName = req.params.F_NickName;
                }
                if (req.params.F_Family_ID) {
                    reqParm.Family_ID = KOC.StringUtils.ToInt(req.params.F_Family_ID, -1);
                }
                reqParm.Create_Date_Between = req.params.F_StartDate ? req.params.F_StartDate : null;
                reqParm.Create_Date_And = req.params.F_EndDate ? req.params.F_EndDate : null;
                //排序
                switch (reqModel.Sort_Col) {
                    case "User_ID":
                    case "NickName":
                    case "Family_ID":
                        break;
                    case "Create_Date":
                        reqModel.Sort_Col = "`User_ID`";
                        break;
                    default:
                        reqModel.Sort_Col = "`User_ID` DESC";
                        reqModel.Sort_Dir = "";
                        break;
                }
                DALFactory.Report.Page.AdminAnchorStatistics(reqParm, reqModel, function (retValue) {
                    if (retValue.hasError) {
                        res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode(retValue.message + "(" + retValue.errorCode + ")", reqModel.Echo));
                        return;
                    }
                    var PageData = CommonUtils.Common.AjaxPage.PageData(reqModel, retValue);
                    KOC.Lodash.forEach(retValue.returnObject, function (ThisValue) {
                        PageData.aaData.push({
                            User_ID: ThisValue.User_ID,
                            NickName: ThisValue.NickName,
                            Family_ID: ThisValue.Family_ID,
                            Sum_BeansAnchor: ThisValue.Sum_BeansAnchor,
                            Sum_LiveDuring: ThisValue.Sum_LiveDuring,
                            Sum_Efftive: ThisValue.Sum_Efftive
                        });
                    });
                    res.jsonp(PageData);
                });
            }
            //endregion
        },
        //endregion
        //region Family_Info 公会信息
        Family_Info: {
            //region FamilyList 公会列表
            FamilyList: function (req, res, _UserData) {
                var reqModel = CommonUtils.Common.AjaxPage.Request(req);
                // 判断权限
                if (!_UserData.IsAdmin) {
                    res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("没有权限", reqModel.Echo));
                    return;
                }
                if (!_UserData.IsLogin) {
                    res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("请登录后使用此功能", reqModel.Echo));
                    return;
                }
                //查询参数
                var reqParm = new DALFactory.User.Page.FamilyInfo_Parm();
                if (reqModel.Filter_Value.length > 0) {
                    switch (reqModel.Filter_Type) {
                        case "Family_Name":
                            //公会名称
                            reqParm.Family_Name = reqModel.Filter_Value;
                            break;
                        case "Family_ID":
                            //公会ID
                            reqParm.Family_ID = reqModel.Filter_Value;
                            break;
                        case "User_ID":
                            //用户ＩＤ
                            reqParm.User_ID = reqModel.Filter_Value;
                            break;
                        case "Account_BankName":
                            //开户银行
                            reqParm.Account_BankName = reqModel.Filter_Value;
                            break;
                        case "Account_BankFullName":
                            //开户银行全称
                            reqParm.Account_BankFullName = reqModel.Filter_Value;
                            break;
                        case "Account_RealName":
                            //开户人姓名
                            reqParm.Account_RealName = reqModel.Filter_Value;
                            break;
                        case "Account_CardNo":
                            //开户帐号
                            reqParm.Account_CardNo = reqModel.Filter_Value;
                            break;
                        case "ContactName":
                            //联系人姓名
                            reqParm.ContactName = reqModel.Filter_Value;
                            break;
                        default:
                            reqParm.FuzzyQuery = reqModel.Filter_Value;
                            break;
                    }
                }
                // reqParm.Family_ID = req.params.Family_ID ? KOC.StringUtils.ToInt(req.params.Family_ID) : null;
                // reqParm.User_ID = req.params.User_ID ? KOC.StringUtils.ToInt(req.params.User_ID) : null;
                reqParm.IDCard = req.params.IDCard ? req.params.IDCard : null;
                reqParm.Phone = req.params.Phone ? req.params.Phone : null;
                reqParm.QQ = req.params.QQ ? req.params.QQ : null;
                reqParm.Email = req.params.Email ? req.params.Email : null;
                reqParm.Status = req.params.F_Status ? KOC.StringUtils.ToInt(req.params.F_Status) : 0;
                reqParm.Create_Date_Between = req.params.F_StartDate ? req.params.F_StartDate : null;
                reqParm.Create_Date_And = req.params.F_EndDate ? req.params.F_EndDate : null;
                //传入Create_Date为字符串“2016-01”，查询一个月内的数据，特殊处理
                if (req.params.Create_Date) {
                    reqParm.Create_Date_Between = req.params.Create_Date ? req.params.Create_Date : null;
                    reqParm.Create_Date_And = req.params.Create_Date ? KOC.Moment(req.params.Create_Date).add(1, 'M').format("YYYY-MM-DD") : null;
                }
                //排序
                switch (reqModel.Sort_Col) {
                    case "Family_ID":
                    case "User_ID":
                    case "Create_Date":
                        break;
                }
                DALFactory.User.Page.FamilyInfo(reqParm, reqModel, function (retValue) {
                    if (retValue.hasError) {
                        res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode(retValue.message + "(" + retValue.errorCode + ")", reqModel.Echo));
                        return;
                    }
                    var PageData = CommonUtils.Common.AjaxPage.PageData(reqModel, retValue);
                    KOC.Lodash.forEach(retValue.returnObject, function (ThisValue) {
                        PageData.aaData.push({
                            Family_ID: ThisValue.Family_ID,
                            Family_Name: ThisValue.Family_Name,
                            User_ID: ThisValue.User_ID,
                            NickName: ThisValue.NickName,
                            RealName: ThisValue.RealName,
                            Anchor_Num: ThisValue.Anchor_Num,
                            Account_BankName: ThisValue.Account_BankName,
                            Account_BankFullName: ThisValue.Account_BankFullName,
                            Account_RealName: ThisValue.Account_RealName,
                            Account_CardNo: ThisValue.Account_CardNo,
                            Family_Phone: ThisValue.Family_Phone,
                            Family_QQ: ThisValue.Family_QQ,
                            Family_Email: ThisValue.Family_Email,
                            Beans: ThisValue.Family_Beans,
                            Beans_Total: ThisValue.Family_Beans_Total,
                            ContactName: ThisValue.ContactName,
                            IDCard: ThisValue.IDCard,
                            Phone: ThisValue.Family_Phone,
                            QQ: ThisValue.Family_QQ,
                            Email: ThisValue.Family_Email,
                            Create_Date: ThisValue.Create_Date ? KOC.Moment(ThisValue.Create_Date).format('YYYY-MM-DD MM:mm:ss') : 0,
                            Status: ThisValue.Status,
                            Create_IP: ThisValue.Create_IP
                        });
                    });
                    res.jsonp(PageData);
                });
            },
            //endregion
            //region FamilyCheck 审批公会申请入驻
            FamilyCheck: function (req, res, _UserData) {
                // 判断权限
                if (!_UserData.IsAdmin) {
                    res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("没有权限"));
                    return;
                }
                if (!_UserData.IsLogin) {
                    res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("请登录后使用此功能"));
                    return;
                }
                var _Value = KOC.Lodash.extend({
                    Family_ID: null,
                    Status: null///审批类型：1-申请成功，2-申请失败
                }, req.params);
                //参数判断
                if (!_Value.Status || !parseInt(_Value.Status) || parseInt(_Value.Status) < 0) {
                    res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("参数错误：Status"));
                    return;
                }
                DALFactory.Business.User_FamilyApplyCheck({
                    Family_ID: _Value.Family_ID,
                    Type: parseInt(_Value.Status),//审批类型：1-申请成功，2-申请失败
                    Admin_ID: _UserData.User_ID,
                    Admin_RealName: _UserData.RealName
                }, function (retValue) {
                    if (retValue.hasError) {
                        res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode(retValue.message));
                        return;
                    }
                    res.jsonp({flag: 0, msg: "审批成功"});
                });
            },
            //endregion
            //region Update 公会信息修改
            Update: function (req, res, _UserData) {
                // 判断权限
                if (!_UserData.IsAdmin) {
                    res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("没有权限"));
                    return;
                }
                if (!_UserData.IsLogin) {
                    res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("请登录后使用此功能"));
                    return;
                }
                var _Value = KOC.Lodash.extend({
                    User_ID: null,
                    ContactName: null,
                    IDCard: null,
                    Account_BankName: null,
                    Account_BankFullName: null,
                    Account_Province: null,
                    Account_City: null,
                    Account_RealName: null,
                    Account_CardNo: null
                }, req.params);
                DALFactory.User.Family_Info.Update_Account({
                    Family_ID: _Value.User_ID,
                    ContactName: _Value.ContactName,
                    Account_BankName: _Value.Account_BankName,
                    Account_BankFullName: _Value.Account_BankFullName,
                    Account_Province: _Value.Account_Province,
                    Account_City: _Value.Account_City,
                    Account_RealName: _Value.Account_RealName,
                    Account_CardNo: _Value.Account_CardNo,
                    IDCard: _Value.IDCard
                }, function (retValue) {
                    if (retValue.hasError) {
                        res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode(retValue.message + "(" + retValue.errorCode + ")"));
                        return;
                    }
                    res.jsonp({flag: 0, msg: "修改成功"});
                });
            },
            //endregion
            //region PageFamilyStatistics 公会统计数据
            PageFamilyStatistics: function (req, res, _UserData) {
                var reqModel = CommonUtils.Common.AjaxPage.Request(req);
                //region 判断权限
                if (!_UserData.IsAdmin) {
                    res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("没有权限", reqModel.Echo));
                    return;
                }
                //endregion
                //查询参数
                var reqParm = new DALFactory.Report.Page.AdminFamilyStatistics_Parm();
                if (reqModel.Filter_Value.length > 0) {
                    switch (reqModel.Filter_Type) {
                        case "Family_Name":
                            reqParm.Family_Name = reqModel.Filter_Value;
                            break;
                        case "Family_ID":
                            reqParm.Family_ID = reqModel.Filter_Value;
                            break;
                        default:
                            reqParm.FuzzyQuery = reqModel.Filter_Value;
                            break;
                    }
                }
                // if (req.params.F_Family_Name) {
                //     reqParm.Family_Name = req.params.Family_Name;
                // }
                // if (req.params.F_Family_ID) {
                //     reqParm.Family_ID = KOC.StringUtils.ToInt(req.params.F_Family_ID, -1);
                // }
                reqParm.Create_Date_Between = req.params.F_StartDate ? req.params.F_StartDate : null;
                reqParm.Create_Date_And = req.params.F_EndDate ? req.params.F_EndDate : null;
                //排序
                switch (reqModel.Sort_Col) {
                    case "Family_ID":
                    case "Family_Name":
                        break;
                    case "Create_Date":
                        reqModel.Sort_Col = "`Family_ID`";
                        break;
                    default:
                        reqModel.Sort_Col = "`Family_ID` DESC";
                        reqModel.Sort_Dir = "";
                        break;
                }
                DALFactory.Report.Page.AdminFamilyStatistics(reqParm, reqModel, function (retValue) {
                    //公会的收入处理
                    var family_cash = {
                        Family_ID: 0,//公会ＩＤ
                        Money: 0,//公会收入金额
                        Revenue_Money: 0,//税收金额
                        Real_Money: 0,//实收收入
                        Anchor_Total_Money: 0,//公会艺人每月的总收入
                        Family_Commission: 0//公会提成
                    };
                    if (retValue.hasError) {
                        res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode(retValue.message + "(" + retValue.errorCode + ")", reqModel.Echo));
                        return;
                    }
                    var PageData = CommonUtils.Common.AjaxPage.PageData(reqModel, retValue);
                    KOC.Lodash.forEach(retValue.returnObject, function (ThisValue) {
                        var Sum_Amt_Anchor = ThisValue.Sum_BeansAnchor / 1000;
                        if (Sum_Amt_Anchor && Sum_Amt_Anchor > 0) {
                            // 公会提成
                            if (Sum_Amt_Anchor < 10000) {
                                family_cash.Family_Commission = 0.2;
                            } else if (Sum_Amt_Anchor >= 10000 && Sum_Amt_Anchor <= 30000) {
                                family_cash.Family_Commission = 0.25;
                            } else if (Sum_Amt_Anchor > 30000 && Sum_Amt_Anchor <= 60000) {
                                family_cash.Family_Commission = 0.3;
                            } else if (Sum_Amt_Anchor > 60000 && Sum_Amt_Anchor <= 100000) {
                                family_cash.Family_Commission = 0.35;
                            } else {
                                family_cash.Family_Commission = 0.4;
                            }
                            //公会收入金额艺人每月的总收入 人民币（元）
                            family_cash.Anchor_Total_Money = Sum_Amt_Anchor && Sum_Amt_Anchor > 0 ? Sum_Amt_Anchor : 0;
                            //公会收入金额 人民币（元）
                            family_cash.Money = Sum_Amt_Anchor * family_cash.Family_Commission;
                            //公会税收金额 人民币（元）
                            family_cash.Revenue_Money = family_cash.Money * 0.03;
                            //公会实收收入 人民币（元）
                            family_cash.Real_Money = family_cash.Money - family_cash.Revenue_Money;
                        } else {
                            family_cash.Family_Commission = 0.2;
                        }
                        PageData.aaData.push({
                            Family_Name: ThisValue.Family_Name,
                            Family_ID: ThisValue.Family_ID,
                            Money: family_cash.Money,
                            Revenue_Money: family_cash.Revenue_Money,
                            Real_Money: family_cash.Real_Money

                        });
                    });
                    res.jsonp(PageData);
                });
            },
            //endregion
            //region Update 公会锁定和解锁
            UpdateFamilyStatus: function (req, res, _UserData) {
                // 判断权限
                if (!_UserData.IsAdmin) {
                    res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("没有权限"));
                    return;
                }
                if (!_UserData.IsLogin) {
                    res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("请登录后使用此功能"));
                    return;
                }
                var _Value = KOC.Lodash.extend({
                    Family_ID: null,
                    Status: null
                }, req.params);
                KOC.Async.series([
                    //公会锁定和解锁
                    function (callback) {
                        DALFactory.User.Family_Info.Update_Status(null, {
                            Family_ID: _Value.Family_ID,
                            Status: _Value.Status == 1 ? 1 : 0//：1-锁定，2-解锁
                        }, function (retValue) {
                            if (retValue.hasError) {
                                callback(retValue);
                                return;
                            }
                            if (retValue.returnObject !== 1) {
                                retValue.hasError = true;
                                retValue.message = "写入公会的状态信息出错，影响行(" + retValue.returnObject + ")";
                                callback(retValue);
                                return;
                            }
                            callback();
                        })
                    },
                    //查询管理员信息
                    function (callback) {
                        DALFactory.User.User_Admin.Info(_UserData.User_ID, function (retValue) {
                            if (retValue.hasError) {
                                callback(retValue);
                                return;
                            }
                            if (!retValue.returnObject) {
                                retValue.hasError = true;
                                retValue.message = '没有该管理员信息';
                                return;
                            }
                            _Value.RealName = retValue.returnObject.RealName;
                            _Value.Phone = retValue.returnObject.Phone;
                            callback();
                        });
                    },
                    //添加log
                    function (callback) {
                        var _Merchant_Operation = {
                            Log_Type: 3,
                            Operate_Type: _Value.Status,
                            Operation: _Value.Status == 1 ? '冻结公会' : '解冻公会',
                            Related_ID: _Value.Family_ID,
                            Data: _Value.Status == 1 ? '冻结公会ID:' + _Value.Family_ID + '的公会账号' : '解冻公会ID:' + _Value.Family_ID + '的公会账号',
                            Admin_ID: _UserData.User_ID,
                            RealName: _Value.RealName,
                            Phone: _Value.Phone,
                            Create_IP: KOC.StringUtils.GetClientIP(req)
                        };
                        DALFactory.Log.Admin_Log.Insert(_Merchant_Operation, function (retValue) {
                            if (retValue.hasError) {
                                callback(retValue);
                                return;
                            }
                            if (retValue.returnObject !== 1) {
                                retValue.hasError = true;
                                retValue.message = "添加冻结/解冻公会信息数据出错，影响行(" + retValue.returnObject + ")";
                                callback(retValue);
                                return;
                            }
                            callback();
                        });
                    }
                ], function (retValue) {
                    if (retValue) {
                        res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode(retValue.message + "(" + retValue.errorCode + ")"));
                        return;
                    }
                    res.jsonp({flag: 0, msg: "修改成功"});
                });
            }
            //endregion
        },
        //endregion
        //region Room_Info 房间信息
        Room_Info: {
            //region UserBlock 房间封号/解封
            RoomBlock: function (req, res, _UserData) {
                // 判断权限
                if (!_UserData.IsAdmin) {
                    res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("没有权限"));
                    return;
                }
                if (!_UserData.IsLogin) {
                    res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("请登录后使用此功能"));
                    return;
                }
                var _Value = KOC.Lodash.extend({
                    User_ID: null,//被封锁房间的艺人ID
                    Data: null,//描述
                    Status: null//1-封锁，0-解封
                }, req.params);
                if (!_Value.User_ID) {
                    res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("被操作的用户的ID不存在"));
                    return;
                }
                DALFactory.Business.RedisRoom_BlockSet({
                    RoomID: _Value.User_ID,
                    Block: _Value.Status == 1 ? true : false,//操作方式 true:冻结 false:解冻
                    AdminID: _UserData.User_ID,
                    Data: _Value.Data,//操作原因
                    Operation: _Value.Status == 1 ? "后台冻结房间" : "后台解冻房间",
                    Create_IP: KOC.StringUtils.GetClientIP(req)
                }, function (retValue) {
                    if (retValue.hasError) {
                        res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode(retValue.message));
                        return;
                    }
                    res.jsonp({flag: 0, msg: "操作成功", data: _Value});
                });
            },
            //endregion
            //region RoomCdn 房间CND修改
            // RoomCdnEdit: function (req, res, _UserData) {
            //     // 判断权限
            //     if (!_UserData.IsAdmin) {
            //         res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("没有权限"));
            //         return;
            //     }
            //     if (!_UserData.IsLogin) {
            //         res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("请登录后使用此功能"));
            //         return;
            //     }
            //     var _Value = KOC.Lodash.extend({
            //         Admin_ID: null,//操作员ＩＤ
            //     }, req.params);
            //     if (!_Value.Admin_ID) {
            //         res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("操作的用户的ID不存在"));
            //         return;
            //     }
            //     KOC.Async.series([
            //         //读取管理员信息
            //         function (callback) {
            //             DALFactory.User.User_Admin.Info(_Value.Admin_ID, function (retValue) {
            //                 if (retValue.hasError) {
            //                     callback(retValue);
            //                     return;
            //                 }
            //                 if (!retValue.returnObject) {
            //                     retValue.hasError = true;
            //                     retValue.message = '没有该管理员信息';
            //                     return;
            //                 }
            //                 _Value.RealName = retValue.returnObject.RealName;
            //                 _Value.Phone = retValue.returnObject.Phone;
            //                 callback();
            //             });
            //         },
            //         //写入log
            //         function (callback) {
            //             var _Merchant_Operation = {
            //                 Log_Type: 3,
            //                 Operation: "修改cnd信息",
            //                 Data: '修改cnd信息',
            //                 Admin_ID: _Value.Admin_ID,
            //                 RealName: _Value.RealName,
            //                 Phone: _Value.Phone,
            //                 Create_IP: KOC.StringUtils.GetClientIP(req)
            //             };
            //             DALFactory.Log.Admin_Log.Insert(_Merchant_Operation, function (retValue) {
            //                 if (retValue.hasError) {
            //                     callback(retValue);
            //                     return;
            //                 }
            //                 if (retValue.returnObject !== 1) {
            //                     retValue.hasError = true;
            //                     retValue.message = "添加员工信息数据出错，影响行(" + retValue.returnObject + ")";
            //                     callback(retValue);
            //                     return;
            //                 }
            //                 callback();
            //             });
            //         }
            //
            //
            //     ], function (retValue) {
            //         if (retValue) {
            //             res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode(retValue.message));
            //             return;
            //         }
            //         res.jsonp({flag: 0, msg: "修改成功"});
            //
            //     });
            // },
            //endregion
            //region  RoomCdnList房间CND修改列表
            // RoomCdnList: function (req, res, _UserData) {
            //     var reqModel = CommonUtils.Common.AjaxPage.Request(req);
            //     // 判断权限
            //     if (!_UserData.IsAdmin) {
            //         res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("没有权限", reqModel.Echo));
            //         return;
            //     }
            //     if (!_UserData.IsLogin) {
            //         res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("请登录后使用此功能", reqModel.Echo));
            //         return;
            //     }
            //     //查询参数
            //     var reqParm = new DALFactory.Log.Page.CdnAdminLog_Parm();
            //     if (reqModel.Filter_Value.length > 0) {
            //         switch (reqModel.Filter_Type) {
            //             case "Admin_ID":
            //                 //用户ID
            //                 reqParm.Admin_ID = reqModel.Filter_Value;
            //                 break;
            //             case "RealName":
            //                 //真实姓名
            //                 reqParm.RealName = reqModel.Filter_Value;
            //                 break;
            //             case "Phone":
            //                 //手机号
            //                 reqParm.Phone = reqModel.Filter_Value;
            //                 break;
            //             default:
            //                 reqParm.FuzzyQuery = reqModel.Filter_Value;
            //                 break;
            //         }
            //     }
            //     reqParm.Create_Date_Between = req.params.F_StartDate ? req.params.F_StartDate : null;
            //     reqParm.Create_Date_And = req.params.F_EndDate ? req.params.F_EndDate : null;
            //     //传入Create_Date为字符串“2016-01”，查询一个月内的数据，特殊处理
            //     if (req.params.Create_Date) {
            //         reqParm.Create_Date_Between = req.params.Create_Date ? req.params.Create_Date : null;
            //         reqParm.Create_Date_And = req.params.Create_Date ? KOC.Moment(req.params.Create_Date).add(1, 'M').format("YYYY-MM-DD") : null;
            //     }
            //     //排序
            //     switch (reqModel.Sort_Col) {
            //         case"Create_Date":
            //             reqModel.Sort_Col = "`Create_Date`";
            //             break;
            //         case"Admin_ID":
            //             reqModel.Sort_Col = "`Admin_ID`";
            //             break;
            //     }
            //     DALFactory.Log.Page.CdnAdminLog(reqParm, reqModel, function (retValue) {
            //         if (retValue.hasError) {
            //             res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode(retValue.message + "(" + retValue.errorCode + ")", reqModel.Echo));
            //             return;
            //         }
            //         var PageData = CommonUtils.Common.AjaxPage.PageData(reqModel, retValue);
            //         KOC.Lodash.forEach(retValue.returnObject, function (ThisValue) {
            //             PageData.aaData.push({
            //                 Log_ID: ThisValue.Log_ID,
            //                 Log_Type: ThisValue.Log_Type,
            //                 Operation: ThisValue.Operation,
            //                 Data: ThisValue.Data,
            //                 RealName: ThisValue.RealName,
            //                 Admin_ID: ThisValue.Admin_ID,
            //                 Phone: ThisValue.Phone,
            //                 Create_Date: ThisValue.Create_Date,
            //                 Create_IP: ThisValue.Create_IP
            //             });
            //         });
            //         res.jsonp(PageData);
            //     });
            // },
            //endregion
        },
        //endregion
        //region Statistics_Info 统计管理信息
        Statistics_Info: {
            //region User_Day_Statistics 每日用户统计信息
            User_Day_Statistics: {
                Page: function (req, res, _UserData) {
                    var reqModel = CommonUtils.Common.AjaxPage.Request(req);
                    // 判断权限
                    if (!_UserData.IsAdmin) {
                        res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("没有权限"));
                        return;
                    }
                    if (!_UserData.IsLogin) {
                        res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("请登录后使用此功能"));
                        return;
                    }
                    var reqParm = new DALFactory.User.Page.UserDayStatistics_Parm();
                    if (reqModel.Filter_Value.length > 0) {
                        switch (reqModel.Filter_Type) {
                            case "ID":
                                reqParm.ID = reqModel.Filter_Value;
                                break;
                            default:
                                reqParm.FuzzyQuery = reqModel.Filter_Value;
                                break;
                        }
                    }
                    reqParm.ID = KOC.StringUtils.ToInt(req.params.F_ID);
                    reqParm.Create_Date = KOC.StringUtils.ToInt(req.params.F_Create_Date);
                    reqParm.Create_Date_Between = req.params.F_StartDate ? KOC.Moment(req.params.F_StartDate)._d : null;
                    reqParm.Create_Date_And = req.params.F_EndDate ? KOC.Moment(req.params.F_EndDate).add(1, 'd')._d : null;
                    if (req.params.F_Create_Date_Between && req.params.F_Create_Date_And) {
                        reqParm.Create_Date_Between = KOC.Moment(req.params.F_Create_Date_Between)._d;
                        reqParm.Create_Date_And = KOC.Moment(req.params.F_Create_Date_And).add(1, 'd')._d;
                    }
                    //排序
                    switch (reqModel.Sort_Col) {
                        case "ID":
                        case "Create_Date":
                            break;
                        default:
                            reqModel.Sort_Col = "`Create_Date`";
                            break;
                    }
                    DALFactory.User.Page.UserDayStatistics(reqParm, reqModel, function (retValue) {
                        if (retValue.hasError) {
                            res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode(retValue.message + "(" + retValue.errorCode + ")", reqModel.Echo));
                            return;
                        }
                        var PageData = CommonUtils.Common.AjaxPage.PageData(reqModel, retValue);
                        KOC.Lodash.forEach(retValue.returnObject, function (ThisValue) {
                            PageData.aaData.push({
                                ID: ThisValue.ID,
                                UV: ThisValue.UV,
                                Regist_Day_Number: ThisValue.Regist_Day_Number,
                                Registration_Conversion: ThisValue.Registration_Conversion,
                                Login_Day_User: ThisValue.Login_Day_User,
                                Regist_Total_User: ThisValue.Regist_Total_User,
                                Actrate: ThisValue.Actrate,
                                Max_Online_User: ThisValue.Max_Online_User,
                                Recharge_Day_User: ThisValue.Recharge_Day_User,
                                Recharge_Day_Coin: ThisValue.Recharge_Day_Coin,
                                Recharge_Total_User: ThisValue.Recharge_Total_User,
                                Recharge_Total_Coin: ThisValue.Recharge_Total_Coin,
                                Pay_Day_User: ThisValue.Pay_Day_User,
                                Pay_Day_Coin: ThisValue.Pay_Day_Coin,
                                ARPU: ThisValue.ARPU,
                                Create_Date: ThisValue.Create_Date ? KOC.Moment(ThisValue.Create_Date).format('YYYY-MM-DD') : '0000-00-00',
                                Web_IP_Number: ThisValue.Web_IP_Number
                            });
                        });
                        res.jsonp(PageData);
                    });
                }
            },
            //endregion
            //region Anchor_Day_Statistics 每日艺人统计信息
            Anchor_Day_Statistics: {
                Page: function (req, res, _UserData) {
                    var reqModel = CommonUtils.Common.AjaxPage.Request(req);
                    // 判断权限
                    if (!_UserData.IsAdmin) {
                        res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("没有权限"));
                        return;
                    }
                    if (!_UserData.IsLogin) {
                        res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("请登录后使用此功能"));
                        return;
                    }
                    var reqParm = new DALFactory.Report.Page.AnchorDayStatistics_Parm();
                    if (reqModel.Filter_Value.length > 0) {
                        switch (reqModel.Filter_Type) {
                            case "User_ID":
                                reqParm.User_ID = reqModel.Filter_Value;
                                break;
                            case "Family_ID":
                                reqParm.Family_ID = reqModel.Filter_Value;
                                break;
                            default:
                                reqParm.FuzzyQuery = reqModel.Filter_Value;
                                break;
                        }
                    }
                    reqParm.Report_Day = KOC.StringUtils.ToInt(req.params.F_Create_Date);
                    reqParm.Create_Date_Between = req.params.F_StartDate ? req.params.F_StartDate : null;
                    reqParm.Create_Date_And = req.params.F_EndDate ? req.params.F_EndDate : null;
                    if (req.params.F_Create_Date_Between && req.params.F_Create_Date_And) {
                        reqParm.Create_Date_Between = req.params.F_Create_Date_Between;
                        reqParm.Create_Date_And = req.params.F_Create_Date_And;
                    }
                    //排序
                    switch (reqModel.Sort_Col) {
                        case "User_ID":
                        case "Report_Day":
                            break;
                        default:
                            reqModel.Sort_Col = "`Report_Day`";
                            break;
                    }
                    DALFactory.Report.Page.AnchorDayStatistics(reqParm, reqModel, function (retValue) {
                        if (retValue.hasError) {
                            res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode(retValue.message + "(" + retValue.errorCode + ")", reqModel.Echo));
                            return;
                        }
                        var PageData = CommonUtils.Common.AjaxPage.PageData(reqModel, retValue);
                        KOC.Lodash.forEach(retValue.returnObject, function (ThisValue) {
                            PageData.aaData.push({
                                Report_Day: ThisValue.Report_Day ? KOC.Moment(ThisValue.Report_Day).format('YYYY-MM-DD') : '0000-00-00',
                                User_ID: ThisValue.User_ID,
                                Family_ID: ThisValue.Family_ID,
                                Family_Name: ThisValue.Family_Name,
                                NickName: ThisValue.NickName,
                                RealName: ThisValue.RealName,
                                Coin: ThisValue.Coin,
                                Beans_Anchor: ThisValue.Beans_Anchor,
                                Beans_Family: ThisValue.Beans_Family,
                                Beans_Platform: ThisValue.Beans_Platform,
                                Live_Count: ThisValue.Live_Count,
                                Live_Duration: ThisValue.Live_Duration,
                                Live_Duration_Efftive: ThisValue.Live_Duration_Efftive,
                                Gift_Count: ThisValue.Gift_Count,
                                Gift_Num: ThisValue.Gift_Num,
                                Gift_Coin: ThisValue.Gift_Coin,
                                Gift_Beans_Anchor: ThisValue.Gift_Beans_Anchor,
                                Gift_Beans_Family: ThisValue.Gift_Beans_Family,
                                Gift_Beans_Platform: ThisValue.Gift_Beans_Platform,
                                Gift_Pond_Count: ThisValue.Gift_Pond_Count,
                                Gift_Pond_Coin: ThisValue.Gift_Pond_Coin,
                                Guardian_Count: ThisValue.Guardian_Count,
                                Guardian_Coin: ThisValue.Guardian_Coin,
                                Guardian_Beans_Anchor: ThisValue.Guardian_Beans_Anchor,
                                Guardian_Beans_Family: ThisValue.Guardian_Beans_Family,
                                Guardian_Beans_Platform: ThisValue.Guardian_Beans_Platform,
                                Horn_Count: ThisValue.Horn_Count,
                                Horn_Coin: ThisValue.Horn_Coin,
                                Horn_Beans_Anchor: ThisValue.Horn_Beans_Anchor,
                                Horn_Beans_Family: ThisValue.Horn_Beans_Family,
                                Horn_Beans_Platform: ThisValue.Horn_Beans_Platform,
                                User_SignUp_Count: ThisValue.User_SignUp_Count
                            });
                        });
                        res.jsonp(PageData);
                    });
                }
            },
            //endregion
            //region Platform_Day_Statistics 平台每日用户统计信息
            Platform_Day_Statistics: {
                Page: function (req, res, _UserData) {
                    var reqModel = CommonUtils.Common.AjaxPage.Request(req);
                    // 判断权限
                    if (!_UserData.IsAdmin) {
                        res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("没有权限"));
                        return;
                    }
                    if (!_UserData.IsLogin) {
                        res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("请登录后使用此功能"));
                        return;
                    }
                    var reqParm = new DALFactory.Report.Page.PlatformDayStatistics_Parm();
                    if (reqModel.Filter_Value.length > 0) {
                        switch (reqModel.Filter_Type) {
                            case "Report_Day":
                                reqParm.Report_Day = reqModel.Filter_Value;
                                break;
                            default:
                                reqParm.FuzzyQuery = reqModel.Filter_Value;
                                break;
                        }
                    }
                    reqParm.Report_Day = KOC.StringUtils.ToInt(req.params.F_Create_Date);
                    reqParm.Create_Date_Between = req.params.F_StartDate ? req.params.F_StartDate : null;
                    reqParm.Create_Date_And = req.params.F_EndDate ? req.params.F_EndDate : null;
                    if (req.params.F_Create_Date_Between && req.params.F_Create_Date_And) {
                        reqParm.Create_Date_Between = req.params.F_Create_Date_Between ? req.params.F_Create_Data_Between : null;
                        reqParm.Create_Date_And = req.params.F_Create_Date_And ? req.params.F_Create_Date_And : null;
                    }
                    //排序
                    switch (reqModel.Sort_Col) {
                        case "Report_Day":
                            break;
                        default:
                            reqModel.Sort_Col = "`Report_Day`";
                            break;
                    }
                    DALFactory.Report.Page.PlatformDayStatistics(reqParm, reqModel, function (retValue) {
                        if (retValue.hasError) {
                            res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode(retValue.message + "(" + retValue.errorCode + ")", reqModel.Echo));
                            return;
                        }
                        var PageData = CommonUtils.Common.AjaxPage.PageData(reqModel, retValue);
                        KOC.Lodash.forEach(retValue.returnObject, function (ThisValue) {
                            PageData.aaData.push({
                                Report_Day: ThisValue.Report_Day ? KOC.Moment(ThisValue.Report_Day).format('YYYY-MM-DD') : '0000-00-00',
                                User_Count: ThisValue.User_Count,
                                User_Count_SignUp: ThisValue.User_Count_SignUp,
                                User_Count_SignIn: ThisValue.User_Count_SignIn,
                                User_Count_VIP: ThisValue.User_Count_VIP,
                                User_Count_Consumption: ThisValue.User_Count_Consumption,
                                User_Coin: ThisValue.User_Coin,
                                User_Beans: ThisValue.User_Beans,
                                Anchor_Count: ThisValue.Anchor_Count,
                                Anchor_Count_SignUp: ThisValue.Anchor_Count_SignUp,
                                Anchor_Count_SignIn: ThisValue.Anchor_Count_SignIn,
                                Anchor_Count_Live: ThisValue.Anchor_Count_Live,
                                Family_Count: ThisValue.Family_Count,
                                Family_Count_SignUp: ThisValue.Family_Count_SignUp,
                                Family_Beans: ThisValue.Family_Beans,
                                Live_Count: ThisValue.Live_Count,
                                Live_Duration: ThisValue.Live_Duration,
                                Recharge_User: ThisValue.Recharge_User,
                                Recharge_Count: ThisValue.Recharge_Count,
                                Recharge_Money: ThisValue.Recharge_Money,
                                Recharge_Coin: ThisValue.Recharge_Coin,
                                Recharge_Poundage: ThisValue.Recharge_Poundage,
                                Gift_Count: ThisValue.Gift_Count,
                                Gift_Num: ThisValue.Gift_Num,
                                Gift_Coin: ThisValue.Gift_Coin,
                                Gift_Beans_Anchor: ThisValue.Gift_Beans_Anchor,
                                Gift_Beans_Family: ThisValue.Gift_Beans_Family,
                                Gift_Beans_Platform: ThisValue.Gift_Beans_Platform,
                                Gift_Pond_Count: ThisValue.Gift_Pond_Count,
                                Gift_Pond_Coin: ThisValue.Gift_Pond_Coin,
                                Guardian_Count: ThisValue.Guardian_Count,
                                Guardian_Coin: ThisValue.Guardian_Coin,
                                Guardian_Beans_Anchor: ThisValue.Guardian_Beans_Anchor,
                                Guardian_Beans_Family: ThisValue.Guardian_Beans_Family,
                                Guardian_Beans_Platform: ThisValue.Guardian_Beans_Platform,
                                Horn_Count: ThisValue.Horn_Count,
                                Horn_Coin: ThisValue.Horn_Coin,
                                Horn_Beans_Anchor: ThisValue.Horn_Beans_Anchor,
                                Horn_Beans_Family: ThisValue.Horn_Beans_Family,
                                Horn_Beans_Platform: ThisValue.Horn_Beans_Platform,
                                VIP_User: ThisValue.VIP_User,
                                VIP_Count: ThisValue.VIP_Count,
                                VIP_Coin: ThisValue.VIP_Coin,
                                Mounts_User: ThisValue.Mounts_User,
                                Mounts_Count: ThisValue.Mounts_Count,
                                Gift_Count_Lucky: ThisValue.Gift_Count_Lucky,
                                Gift_Coin_Lucky: ThisValue.Gift_Coin_Lucky,
                                Gift_Lucky_Coin: ThisValue.Gift_Lucky_Coin,
                                Gift_Num_Lucky: ThisValue.Gift_Num_Lucky,
                                Lottery_Coin: ThisValue.Lottery_Coin,
                                Lottery_CategoryIron_Coin: ThisValue.Lottery_CategoryIron_Coin,
                                Lottery_CategoryCopper_Coin: ThisValue.Lottery_CategoryCopper_Coin,
                                Lottery_CategorySilver_Coin: ThisValue.Lottery_CategorySilver_Coin,
                                Lottery_CategoryGold_Coin: ThisValue.Lottery_CategoryGold_Coin,
                                Lottery_Count: ThisValue.Lottery_Count,
                                Lottery_CategoryIron_Count: ThisValue.Lottery_CategoryIron_Count,
                                Lottery_CategoryCopper_Count: ThisValue.Lottery_CategoryCopper_Count,
                                Lottery_CategorySilver_Count: ThisValue.Lottery_CategorySilver_Count,
                                Lottery_CategoryGold_Count: ThisValue.Lottery_CategoryGold_Count,
                                Mounts_Coin: ThisValue.Mounts_Coin
                            });
                        });
                        res.jsonp(PageData);
                    });
                }
            },
            //endregion
            //region Channel_Day_Statistics 渠道统计信息
            Channel_Day_Statistics: {
                Page: function (req, res, _UserData) {
                    var reqModel = CommonUtils.Common.AjaxPage.Request(req);
                    // 判断权限
                    if (!_UserData.IsAdmin) {
                        res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("没有权限"));
                        return;
                    }
                    if (!_UserData.IsLogin) {
                        res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("请登录后使用此功能"));
                        return;
                    }
                    var reqParm = new DALFactory.Report.Page.ChannelDayStatistics_Parm();
                    if (reqModel.Filter_Value.length > 0) {
                        switch (reqModel.Filter_Type) {
                            case "Channel_ID":
                                reqParm.Channel_ID = reqModel.Filter_Value;
                                break;
                            default:
                                reqParm.FuzzyQuery = reqModel.Filter_Value;
                                break;
                        }
                    }
                    reqParm.Create_Date_Between = req.params.F_StartDate ? req.params.F_StartDate : null;
                    reqParm.Create_Date_And = req.params.F_EndDate ? req.params.F_EndDate : null;
                    if (req.params.F_Create_Date_Between && req.params.F_Create_Date_And) {
                        reqParm.Create_Date_Between = req.params.F_Create_Date_Between;
                        reqParm.Create_Date_And = req.params.F_Create_Date_And;
                    }
                    //排序
                    switch (reqModel.Sort_Col) {
                        case "Channel_ID":
                        case "Report_Day":
                            break;
                        default:
                            reqModel.Sort_Col = "`Report_Day`";
                            break;
                    }
                    DALFactory.Report.Page.ChannelDayStatistics(reqParm, reqModel, function (retValue) {
                        if (retValue.hasError) {
                            res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode(retValue.message + "(" + retValue.errorCode + ")", reqModel.Echo));
                            return;
                        }
                        var PageData = CommonUtils.Common.AjaxPage.PageData(reqModel, retValue);
                        KOC.Lodash.forEach(retValue.returnObject, function (ThisValue) {
                            var Channel_ID = null;
                            var Channel_Name = {};
                            if (ThisValue.Channel_ID.length < 3) {
                                ThisValue.ChannelName = '未知';
                            } else {
                                Channel_ID = ThisValue.Channel_ID.substring(0, 3);
                                Channel_Name = CommonUtils.Statistics.Channel.fnInfo(Channel_ID);
                                ThisValue.ChannelName = Channel_Name ? Channel_Name.Name : '未知';
                            }
                            PageData.aaData.push({
                                Report_Day: ThisValue.Report_Day ? KOC.Moment(ThisValue.Report_Day).format('YYYY-MM-DD') : '0000-00-00',
                                Channel_ID: ThisValue.Channel_ID,
                                Channel_Name: ThisValue.ChannelName,
                                Recharge_User: ThisValue.Recharge_User,
                                Recharge_Money: ThisValue.Recharge_Money,
                                Recharge_Count: ThisValue.Recharge_Count,
                                Recharge_Coin: ThisValue.Recharge_Coin,
                                Recharge_Poundage: ThisValue.Recharge_Poundage,
                                User_Count_SignIn: ThisValue.User_Count_SignIn,
                                User_Count_SignUp: ThisValue.User_Count_SignUp
                            });
                        });
                        res.jsonp(PageData);
                    });
                }
            },
            //endregion
        },
        //endregion
        //region FeedBack_Manage 反馈管理信息
        FeedBack_Manage: {
            Page: function (req, res, _UserData) {
                var reqModel = CommonUtils.Common.AjaxPage.Request(req);
                // 判断权限
                if (!_UserData.IsAdmin) {
                    res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("没有权限"));
                    return;
                }
                if (!_UserData.IsLogin) {
                    res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("请登录后使用此功能"));
                    return;
                }
                var reqParm = new DALFactory.User.Page.UserFeedBack_Parm();
                if (reqModel.Filter_Value.length > 0) {
                    switch (reqModel.Filter_Type) {
                        case "ID":
                            reqParm.ID = reqModel.Filter_Value;
                            break;
                        case "User_ID":
                            reqParm.User_ID = reqModel.Filter_Value;
                            break;
                        case "NickName":
                            reqParm.NickName = reqModel.Filter_Value;
                            break;
                        default:
                            reqParm.FuzzyQuery = reqModel.Filter_Value;
                            break;
                    }
                }
                reqParm.QQ = req.params.F_QQ ? req.params.F_QQ : null;
                reqParm.Create_Date_Between = req.params.F_StartDate ? req.params.F_StartDate : null;
                reqParm.Create_Date_And = req.params.F_EndDate ? req.params.F_EndDate : null;
                //排序
                switch (reqModel.Sort_Col) {
                    case "ID":
                    case "User_ID":
                    case "NickName":
                    case "Create_Date":
                        break;
                    default:
                        reqModel.Sort_Col = "`Create_Date`";
                        break;
                }
                DALFactory.User.Page.UserFeedBack(reqParm, reqModel, function (retValue) {
                    if (retValue.hasError) {
                        res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode(retValue.message + "(" + retValue.errorCode + ")", reqModel.Echo));
                        return;
                    }
                    var PageData = CommonUtils.Common.AjaxPage.PageData(reqModel, retValue);
                    KOC.Lodash.forEach(retValue.returnObject, function (ThisValue) {
                        PageData.aaData.push({
                            ID: ThisValue.ID,
                            User_ID: ThisValue.User_ID,
                            NickName: ThisValue.NickName,
                            Relate_User_ID: ThisValue.Relate_User_ID,
                            Relate_NickName: ThisValue.Relate_NickName,
                            Type: ThisValue.Type,
                            QQ: ThisValue.QQ,
                            Phone: ThisValue.Phone,
                            Message: ThisValue.Message,
                            Create_Date: ThisValue.Create_Date,
                            Create_IP: ThisValue.Create_IP
                        });
                    });
                    res.jsonp(PageData);
                });
            }
        },
        //endregion
        //region Admin_Manage 管理员管理
        Admin_Manage: {
            //region Page 管理员列表
            Page: function (req, res, _UserData) {
                var reqModel = CommonUtils.Common.AjaxPage.Request(req);
                // 判断权限
                if (!_UserData.IsAdmin) {
                    res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("没有权限"));
                    return;
                }
                if (!_UserData.IsLogin) {
                    res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("请登录后使用此功能"));
                    return;
                }
                var reqParm = new DALFactory.User.Page.UserAdminOld_Parm();
                if (reqModel.Filter_Value.length > 0) {
                    switch (reqModel.Filter_Type) {
                        case "User_ID":
                            reqParm.User_ID = reqModel.Filter_Value;
                            break;
                        case "RealName":
                            reqParm.RealName = reqModel.Filter_Value;
                            break;
                        case "NickName":
                            reqParm.NickName = reqModel.Filter_Value;
                            break;
                        case "Phone":
                            reqParm.Phone = reqModel.Filter_Value;
                            break;
                        default:
                            reqParm.FuzzyQuery = reqModel.Filter_Value;
                            break;
                    }
                }

                reqParm.Status = req.params.F_Status ? KOC.StringUtils.ToInt(req.params.F_Status) : null;
                reqParm.Create_Date_Between = req.params.F_StartDate ? KOC.Moment(req.params.F_StartDate)._d : null;
                reqParm.Create_Date_And = req.params.F_EndDate ? KOC.Moment(req.params.F_EndDate)._d : null;
                //排序
                switch (reqModel.Sort_Col) {
                    case "Create_Date":
                    case "User_ID":
                    case "RealName":
                        break;
                    default:
                        reqModel.Sort_Col = "`Create_Date`";
                        break;
                }
                DALFactory.User.Page.UserAdminOld(reqParm, reqModel, function (retValue) {
                    if (retValue.hasError) {
                        res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode(retValue.message + "(" + retValue.errorCode + ")", reqModel.Echo));
                        return;
                    }
                    var PageData = CommonUtils.Common.AjaxPage.PageData(reqModel, retValue);
                    KOC.Lodash.forEach(retValue.returnObject, function (ThisValue) {
                        PageData.aaData.push({
                            User_ID: ThisValue.User_ID,
                            NickName: ThisValue.NickName,
                            RealName: ThisValue.RealName,
                            Phone: ThisValue.Phone,
                            Login_Last_Date: ThisValue.Login_Last_Date,
                            IsMaster: ThisValue.IsMaster,
                            Create_Date: ThisValue.Create_Date,
                            Status: ThisValue.Status,
                        });
                    });
                    res.jsonp(PageData);
                });
            },
            //endregion
            //region LogList 管理员日志列表
            LogList: function (req, res, _UserData) {
                var reqModel = CommonUtils.Common.AjaxPage.Request(req);
                // 判断权限
                if (!_UserData.IsAdmin) {
                    res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("没有权限"));
                    return;
                }
                if (!_UserData.IsLogin) {
                    res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode("请登录后使用此功能"));
                    return;
                }
                var reqParm = new DALFactory.Log.Page.UserAdminLog_Parm();
                if (reqModel.Filter_Value.length > 0) {
                    switch (reqModel.Filter_Type) {
                        case "Admin_ID":
                            reqParm.Admin_ID = reqModel.Filter_Value;
                            break;
                        case "Related_ID":
                            reqParm.Related_ID = reqModel.Filter_Value;
                            break;
                        case "RealName":
                            reqParm.RealName = reqModel.Filter_Value;
                            break;
                        case "Operation":
                            reqParm.Operation = reqModel.Filter_Value;
                            break;
                        case "Phone":
                            reqParm.Phone = reqModel.Filter_Value;
                            break;
                        default:
                            reqParm.FuzzyQuery = reqModel.Filter_Value;
                            break;
                    }
                }
                reqParm.Create_Date_Between = req.params.F_StartDate ? req.params.F_StartDate : null;
                reqParm.Create_Date_And = req.params.F_EndDate ? req.params.F_EndDate : null;
                //排序
                switch (reqModel.Sort_Col) {
                    case "Create_Date":
                    case "Log_ID":
                    case "RealName":
                    case "Admin_ID":
                        break;
                    default:
                        reqModel.Sort_Col = "`Create_Date`";
                        break;
                }
                DALFactory.Log.Page.UserAdminLog(reqParm, reqModel, function (retValue) {
                    if (retValue.hasError) {
                        res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode(retValue.message + "(" + retValue.errorCode + ")", reqModel.Echo));
                        return;
                    }
                    var PageData = CommonUtils.Common.AjaxPage.PageData(reqModel, retValue);
                    KOC.Lodash.forEach(retValue.returnObject, function (ThisValue) {
                        PageData.aaData.push({
                            Log_ID: ThisValue.Log_ID,
                            Log_Type: ThisValue.Log_Type,
                            Operate_Type: ThisValue.Operate_Type,
                            Operation: ThisValue.Operation,
                            Data: ThisValue.Data,
                            Related_ID: ThisValue.Related_ID,
                            Admin_ID: ThisValue.Admin_ID,
                            RealName: ThisValue.RealName,
                            Phone: ThisValue.Phone,
                            Create_Date: ThisValue.Create_Date,
                            Create_IP: ThisValue.Create_IP
                        });
                    });
                    res.jsonp(PageData);
                });
            },
            //endregion
            //region Enter_Base 添加管理员
            Enter_Base: function (req, res) {
                //region 判断权限
                if (StateData.RightCode.Admin(req, res, "{System}[Manager](Add)") !== 0) {
                    res.jsonp({flag: -1, msg: "没有权限"});
                    return;
                }
                //endregion
                var _User_ID = KOC.StringUtils.ToInt(req.params.User_ID, -1);
                var _User_Admin = {
                    User_ID: _User_ID,
                    RealName: KOC.StringUtils.ToString(req.params.RealName),
                    Phone: KOC.StringUtils.ToString(req.params.Phone),
                    IsMaster: false,
                    RightCode: KOC.StringUtils.ToString(req.params.RightCode),
                    Status: KOC.StringUtils.ToInt(req.params.Status),
                    Create_IP: KOC.StringUtils.GetClientIP(req)
                };
                var _Conn = null;
                KOC.Async.series([
                    //读取用户信息
                    function (callback) {
                        if (_User_ID <= 0) {
                            callback();
                            return;
                        }
                        DALFactory.User.User_Info.Info(_User_Admin.User_ID, function (retValue) {
                            if (retValue.hasError) {
                                callback(retValue);
                                return;
                            }
                            if (!retValue.returnObject) {
                                retValue.hasError = true;
                                retValue.message = "无此员工信息";
                                callback(retValue);
                                return;
                            }
                            if (retValue.returnObject.IsAdmin) {
                                retValue.hasError = true;
                                retValue.message = "该用户已经是管理员了";
                                callback(retValue);
                                return;
                            }
                            callback();
                        });
                    },
                    //读取管理员信息
                    function (callback) {
                        if (_User_ID <= 0) {
                            callback();
                            return;
                        }
                        DALFactory.User.User_Admin.Info(_User_Admin.User_ID, function (retValue) {
                            if (retValue.hasError) {
                                callback(retValue);
                                return;
                            }
                            if (retValue.returnObject) {
                                retValue.hasError = true;
                                retValue.message = "该用户已经是管理员了";
                                callback(retValue);
                                return;
                            }
                            callback();
                        });
                    },
                    //判断手机号码是否重复
                    function (callback) {
                        if (_User_ID > 0) {
                            callback();
                            return;
                        }
                        DALFactory.User.User_Admin.Info_Phone(_User_Admin.Phone, function (retValue) {
                            if (retValue.hasError) {
                                callback(retValue);
                                return;
                            }
                            if (retValue.returnObject) {
                                retValue.hasError = true;
                                retValue.message = "此手机号码已被注册";
                                callback(retValue);
                                return;
                            }
                            callback();
                        });
                    },
                    //开启事物
                    function (callback) {
                        KOC.MysqlHelper.TranOpen(Config.Mysql.DB.User, function (retValue) {
                            if (retValue.hasError) {
                                callback(retValue);
                                return;
                            }
                            _Conn = retValue.returnObject;
                            callback();
                        });
                    },
                    //增加
                    function (callback) {
                        if (_User_ID < 0) {
                            callback();
                            return;
                        }
                        DALFactory.User.User_Admin.Insert(_Conn, _User_Admin, function (retValue) {
                            if (retValue.hasError) {
                                callback(retValue);
                                return;
                            }
                            _User_Admin.User_ID = KOC.StringUtils.ToInt(retValue.GetValue("insertId"), -1);
                            callback();
                        });
                    },
                    //修改用户信息状态
                    function (callback) {
                        if (_User_ID <= 0) {
                            callback();
                            return;
                        }
                        DALFactory.User.User_Info.Update_IsAdmin(_Conn, {
                            User_ID: _User_ID,
                            Status: _User_Admin.Status
                        }, function (retValue) {
                            if (retValue.hasError) {
                                callback(retValue);
                                return;
                            }
                            if (retValue.returnObject !== 1) {
                                retValue.hasError = true;
                                retValue.message = "修改员工信息数据出错，影响行(" + retValue.returnObject + ")";
                                callback(retValue);
                                return;
                            }
                            callback();
                        });
                    }
                    //写入操作日志
                    //function (callback) {
                    //    var _Merchant_Operation = {
                    //        Log_Type: 15,
                    //        Operate_Type: _Employee_ID <= 0 ? 1 : 2,
                    //        Order_No: _User_Admin.Employee_ID,
                    //        Title: _Employee_ID <= 0 ? "增加员工" : "修改员工",
                    //        Operation: "",
                    //        Data: JSON.stringify(_User_Admin),
                    //        Merchant_ID: _UserData.Merchant_ID,
                    //        Store_ID: _UserData.Store_ID,
                    //        Employee_ID: _UserData.Employee_ID,
                    //        RealName: _UserData.RealName,
                    //        Phone: _UserData.Phone,
                    //        Create_IP: KOC.StringUtils.GetClientIP(req)
                    //    };
                    //    _DALFactory.Log.Merchant_Operation.Insert(_Merchant_Operation, function (retValue) {
                    //        if (retValue.hasError) {
                    //            callback(retValue);
                    //            return;
                    //        }
                    //        callback();
                    //    });
                    //}
                ], function (retValue) {
                    if (retValue) {
                        KOC.MysqlHelper.TranRollback(_Conn, function () {
                            res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode(retValue.message));
                        });
                        return;
                    }
                    KOC.MysqlHelper.TranCommit(_Conn, function (retValue) {
                        if (retValue.hasError) {
                            res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode(retValue.message));
                            return;
                        }
                        res.jsonp({flag: 0, msg: "添加成功"});
                    });
                });
            },
            //endregion
            //region Edit_Base 修改管理员
            Edit_Base: function (req, res) {
                //region 判断权限
                if (StateData.RightCode.Admin(req, res, "{System}[Manager](Edit)") !== 0) {
                    res.jsonp({flag: -1, msg: "没有权限"});
                    return;
                }
                //endregion
                var _User_ID = KOC.StringUtils.ToInt(req.params.User_ID, -1);
                var _User_Admin = {
                    User_ID: _User_ID,
                    RealName: KOC.StringUtils.ToString(req.params.RealName),
                    Phone: KOC.StringUtils.ToString(req.params.Phone),
                    IsMaster: false,
                    RightCode: KOC.StringUtils.ToString(req.params.RightCode),
                    Status: KOC.StringUtils.ToInt(req.params.Status),
                    Create_IP: KOC.StringUtils.GetClientIP(req)
                };
                var _Conn = null;
                KOC.Async.series([
                    //读取用户
                    function (callback) {
                        if (_User_ID <= 0) {
                            callback();
                            return;
                        }
                        DALFactory.User.User_Info.Info(_User_Admin.User_ID, function (retValue) {
                            if (retValue.hasError) {
                                callback(retValue);
                                return;
                            }
                            if (!retValue.returnObject) {
                                retValue.hasError = true;
                                retValue.message = "无此员工信息";
                                callback(retValue);
                                return;
                            }
                            _User_Admin.IsAdmin = KOC.StringUtils.ToInt(retValue.returnObject.IsAdmin);
                            callback();
                        });
                    },
                    //读取管理员信息
                    function (callback) {
                        if (_User_ID <= 0) {
                            callback();
                            return;
                        }
                        DALFactory.User.User_Admin.Info(_User_Admin.User_ID, function (retValue) {
                            if (retValue.hasError) {
                                callback(retValue);
                                return;
                            }
                            if (!retValue.returnObject) {
                                retValue.hasError = true;
                                retValue.message = "该用户不是管理员";
                                callback(retValue);
                                return;
                            }
                            callback();
                        });
                    },
                    //判断手机号码是否重复
                    function (callback) {
                        if (_User_ID > 0) {
                            callback();
                            return;
                        }
                        DALFactory.User.User_Admin.Info_Phone(_User_Admin.Phone, function (retValue) {
                            if (retValue.hasError) {
                                callback(retValue);
                                return;
                            }
                            if (retValue.returnObject) {
                                retValue.hasError = true;
                                retValue.message = "此手机号码已被注册";
                                callback(retValue);
                                return;
                            }
                            callback();
                        });
                    },
                    //开启事物
                    function (callback) {
                        KOC.MysqlHelper.TranOpen(Config.Mysql.DB.User, function (retValue) {
                            if (retValue.hasError) {
                                callback(retValue);
                                return;
                            }
                            _Conn = retValue.returnObject;
                            callback();
                        });
                    },
                    //修改user_admin
                    function (callback) {
                        if (_User_ID < 0) {
                            callback();
                            return;
                        }
                        DALFactory.User.User_Admin.Update(_Conn, _User_Admin, function (retValue) {
                            if (retValue.hasError) {
                                callback(retValue);
                                return;
                            }
                            if (retValue.returnObject !== 1) {
                                retValue.hasError = true;
                                retValue.message = "修改员工信息数据出错，影响行(" + retValue.returnObject + ")";
                                callback(retValue);
                                return;
                            }
                            callback();
                        });
                    },
                    //修改用户信息状态
                    function (callback) {
                        if (_User_ID <= 0) {
                            callback();
                            return;
                        }
                        if (_User_Admin.Status == 0 && _User_Admin.IsAdmin > 0) {
                            callback();
                            return;
                        }
                        DALFactory.User.User_Info.Update_IsAdmin(_Conn, {
                            User_ID: _User_ID,
                            Status: _User_Admin.Status
                        }, function (retValue) {
                            if (retValue.hasError) {
                                callback(retValue);
                                return;
                            }
                            if (retValue.returnObject !== 1) {
                                retValue.hasError = true;
                                retValue.message = "修改员工信息数据出错，影响行(" + retValue.returnObject + ")";
                                callback(retValue);
                                return;
                            }
                            callback();
                        });
                    }
                ], function (retValue) {
                    if (retValue) {
                        KOC.MysqlHelper.TranRollback(_Conn, function () {
                            res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode(retValue.message));
                        });
                        return;
                    }
                    KOC.MysqlHelper.TranCommit(_Conn, function (retValue) {
                        if (retValue.hasError) {
                            res.jsonp(CommonUtils.Common.AjaxPage.ErrorCode(retValue.message));
                            return;
                        }
                        res.jsonp({flag: 0, msg: "修改成功"});
                    });
                });
            },
            //endregion
        }
        //endregion
    }
};